pi-model-manager 0.4.8 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md CHANGED
@@ -10,118 +10,21 @@ A TUI model and provider manager for [Pi](https://github.com/earendil-works/pi).
10
10
 
11
11
  > This extension requires Pi `>=0.87.0` and Node.js `22.x >=22.21.0` or `>=24.5.0`. Configuration locking on Windows requires PowerShell 7 (`pwsh`). Provider proxies are not supported under Bun.
12
12
 
13
- ## Interface preview
13
+ ## Management window
14
14
 
15
- The screens below are rendered by the real components at 88 columns. In practice column widths adapt to your data, the selected row is highlighted with a background colour, and column values are semantically coloured. This preview uses Simplified Chinese; the live UI can switch between Simplified Chinese and English from the dashboard.
15
+ `/model-manager` opens a centered overlay. Browsing, editing, selection, and confirmation stay in the same window.
16
16
 
17
- ```text
18
- ────────────────────────────────────────────────────────────────────────────────────────
19
- /model-manager
20
- 4 接入 · 5 模型 · 0 内置抓包 · 0 自定义请求头
21
-
22
- 接入 API 模型 请求头 代理 认证 状态
23
- ❯ OpenAI (openai) Responses 2 Auto→Codex direct env ready
24
- Claude (claude) Claude 1 ClaudeCode direct env ready
25
- Gemini (gemini) Gemini 1 Auto→不添加 direct env ready
26
- Local vLLM (local) Chat 1 Off proxy key ready
27
-
28
- ────────────────────────────────────────────────────────────────────────────────────────
29
- OpenAI (openai)
30
- endpoint https://api.openai.com/v1
31
- proxy direct
32
- api Responses · headers Auto→Codex · auth env
33
- models gpt-5.6-sol, gpt-5.6-terra
34
-
35
- ↑↓ 选择 Enter 进入 N 新建接入 D 删除接入 H 请求头 Esc 退出 / 搜索
36
- ────────────────────────────────────────────────────────────────────────────────────────
37
- ```
38
-
39
- <details>
40
- <summary>Show the other four screens</summary>
41
-
42
- ### Models inside a provider
43
-
44
- ```text
45
- ────────────────────────────────────────────────────────────────────────────────────────
46
- /model-manager / OpenAI
47
- Responses · 2 模型 · headers Auto→Codex · proxy direct · auth env
48
- endpoint https://api.openai.com/v1
49
-
50
- 模型 ID 显示名 输入 Thinking 上下文
51
- ❯ gpt-5.6-sol 默认 文本,视觉 开 1.1M
52
- gpt-5.6-terra 默认 文本,视觉 开 1.1M
53
-
54
- ↑↓ 选择 Enter 编辑模型 A 添加模型 E 编辑接入 D 删除模型 Esc 返回 / 搜索
55
- ────────────────────────────────────────────────────────────────────────────────────────
56
- ```
57
-
58
- ### Provider setup
59
-
60
- ```text
61
- ────────────────────────────────────────────────────────────────────────────────────────
62
- 编辑接入 openai
63
- API Responses · 请求头 自动推荐(Auto→Codex)
64
- 接入 ID 必填,且不能与已有或 pi 内置接入重复
65
- Ctrl+S 保存并同步 models.json;不切换当前会话模型
66
-
67
- 接入 ID openai
68
- 显示名称 OpenAI
69
- API 协议 OpenAI Responses
70
- ❯ Base URL https://api.openai.com/v1
71
- 本机代理 关闭
72
- 代理地址 关闭时不使用
73
- API key $OPENAI_API_KEY
74
- 认证头 默认
75
- 请求头 自动推荐(Auto→Codex)
76
-
77
- ↑↓ 选择 ←→ 切换选项 Enter 编辑 Ctrl+S 保存并同步 Esc 返回
78
- ────────────────────────────────────────────────────────────────────────────────────────
79
- ```
80
-
81
- ### Model capabilities
82
-
83
- ```text
84
- ────────────────────────────────────────────────────────────────────────────────────────
85
- 编辑模型 gpt-5.6-sol
86
- 接入 openai · API Responses
87
- Ctrl+S 保存并启用模型;不切换当前会话模型
88
-
89
- 模型 ID gpt-5.6-sol
90
- 重新拉取 上游模型列表
91
- 显示名称 默认 = 模型 ID
92
- ❯ 视觉支持 ◀ 开启 ▶
93
- Thinking ◀ 开启 ▶
94
- Fast mode ◀ 标准 ▶
95
- 上下文窗口 ◀ 1050000 ▶
96
- 最大输出 ◀ 128000 ▶
97
- 请求头 跟随接入(Auto→Codex)
98
-
99
- ↑↓ 选择 ←→ 切换选项 Enter 编辑 Ctrl+S 保存并启用 Esc 返回
100
- ────────────────────────────────────────────────────────────────────────────────────────
101
- ```
17
+ | Area | Contents |
18
+ | --- | --- |
19
+ | Header | Current page path and unsaved indicator |
20
+ | Full-width list | Providers, models, or settings; only one interactive list at a time |
21
+ | Footer | Selected-item details or results, followed by this page's shortcuts |
102
22
 
103
- ### Model discovery
23
+ The window is capped at 128 columns and 32 rows. Short lists shrink to their content; long lists scroll within the available height. The home table shows provider IDs, names, protocols, model counts, authentication methods, proxy status, and endpoints as space allows, with selected-provider details below. Narrow terminals hide secondary columns and shorten shortcut labels; short terminals reduce details without changing navigation. Resizing preserves drafts and search without restarting discovery. Colors follow the Pi theme: a full-row highlight marks selection, titles, selected rows, and shortcuts use bold text, and unsaved changes, success, and errors use semantic colors. Actual font size is controlled by the terminal.
104
24
 
105
- ```text
106
- ────────────────────────────────────────────────────────────────────────────────────────
107
- 选择模型(openai)
108
- 搜索: <直接输入搜索>
109
- 匹配 9 / 9 · 页码 1 / 2
110
-
111
- gpt-5.3
112
- gpt-5.4
113
- gpt-5.4-mini
114
- gpt-5.5
115
- gpt-5.6-luna
116
- ❯ gpt-5.6-sol ● 当前
117
- gpt-5.6-terra
118
- gpt-image-2
119
-
120
- ↑↓ 选择 · ←→/PgUp/PgDn 翻页 · 输入搜索 · Backspace 删除 · Enter 确认 · Esc 取消
121
- ────────────────────────────────────────────────────────────────────────────────────────
122
- ```
25
+ Provider settings are grouped into Connection, Authentication & headers, and Transport & compatibility. Left/right adjusts enums, switches, and numeric presets. Text uses native Input directly in the selected row; header JSON uses the native multiline Editor in the same window. Pressing `Enter` on Base URL starts with an empty input for a new provider and preserves the current address for a saved provider. Cancelling input leaves the draft unchanged. API keys are masked by default; use `←` / `→` on the API key row to show/hide the configured value. Leaving the editor hides it again. Environment variables and commands are shown as references, never evaluated. `Enter` accepts a replacement; empty input keeps the value. Clearing a credential is a separate field action. Proxy URL editing starts empty and preserves the stored URL when left blank; it never pre-fills saved proxy credentials.
123
26
 
124
- </details>
27
+ Saving keeps the current field open. If persistence succeeds but registry or runtime refresh fails, a warning explicitly reports that the configuration was saved. The editor adopts the saved identity, allowing further edits or `/reload` to retry activation. Leaving a modified object offers Save and continue / Discard changes / Keep editing. Providers save independently without any models. Failed discovery, an empty result, or deleting the last model never deletes a saved provider.
125
28
 
126
29
  ## Features
127
30
 
@@ -132,9 +35,10 @@ Ctrl+S 保存并启用模型;不切换当前会话模型
132
35
  - Fetch model IDs from compatible upstream APIs or enter them manually.
133
36
  - Configure context window, maximum output, vision support, and reasoning support.
134
37
  - Choose Anthropic Adaptive Thinking or Legacy Thinking.
38
+ - All protocols expose `minimal / low / medium / high / xhigh / max` and send the user's selected level by the same name (adjusting case when the protocol requires it). Availability is not restricted by model ID or existing `thinkingLevelMap`; the upstream service decides what it supports.
135
39
  - Select Standard, Fast (`priority`), or Ultrafast (`ultrafast`) service tiers per OpenAI Responses model.
136
40
  - Route each provider directly or through its own HTTP(S) proxy.
137
- - Use recommended, disabled, Claude Code, Codex, or custom client-header profiles.
41
+ - Use recommended, disabled, Claude Code, Codex, Antigravity CLI, or custom client-header profiles.
138
42
  - Reference API keys as literals, `$ENV_VAR` / `${ENV_VAR}`, or Pi `!command` values.
139
43
  - Persist configuration with a cross-process lock and recoverable two-file transactions, then re-register managed providers after saving.
140
44
 
@@ -175,21 +79,29 @@ pi install npm:pi-model-manager
175
79
  /model-manager
176
80
  ```
177
81
 
178
- 3. Manage providers from the dashboard:
82
+ 3. Navigate with arrows and page-specific shortcuts:
179
83
 
180
84
  | Key | Action |
181
85
  | --- | --- |
182
- | `Enter` | Open the selected provider and manage its models |
183
- | `N` | Create a provider and its first model |
184
- | `D` | Delete the selected provider |
185
- | `H` | Manage reusable header profiles |
186
- | `L` | Switch the UI language (Simplified Chinese / English); the choice applies immediately and is saved |
187
- | `/` | Search the current list; `Tab` leaves the input while keeping the filter, `Esc` clears it |
188
- | `Esc` | Go back or exit |
189
-
190
- Single-letter shortcuts are case-insensitive. The footer hints wrap per item, so they are never truncated away on narrow terminals.
191
-
192
- 4. In an editor, use `↑` / `↓` to select a field and press `Enter` to edit it. Toggle switch fields in place with `←` / `→`, then press `Ctrl+S` to save.
86
+ | `↑` / `↓` | Select a provider, model, field, or option |
87
+ | `←` / `→` | Adjust enums, switches, or numeric presets; show/hide the API key; move the cursor during input |
88
+ | `Tab` | Switch search input/list, or header name/value while editing a header row |
89
+ | `Enter` | Open, edit, or confirm; when adding a header, advance from name to value, then apply the row |
90
+ | `Ctrl+S` | Validate and save the object without leaving it |
91
+ | `Ctrl+Enter` | Apply multiline JSON to the object draft |
92
+ | `/` | Start searching the current list |
93
+ | `PgUp` / `PgDn` | Page by visible rows, or scroll long confirmation details |
94
+ | `?` | Read full field descriptions or result messages |
95
+ | `Esc` | Cancel a field; clear active search; otherwise go back one page, or exit from the provider list |
96
+ | `N` / `D` / `H` / `L` | Provider list: create / delete provider / header library / choose language directly |
97
+ | `A` / `E` / `D` | Model list: add model / edit provider / delete model |
98
+ | `N` / `D` | Header list: create / delete custom profile; `Enter` views a built-in profile |
99
+ | `C` | Built-in header details: copy to a custom profile |
100
+ | `A` / `D` / `T` / `J` | Header editor: add field / delete selected field / template / bulk JSON |
101
+
102
+ Letter shortcuts are case-insensitive and remain ordinary characters during text entry or search. `Home` / `End` jump to list boundaries, or move the text cursor during input. A saved provider form also offers `A` to add a model.
103
+
104
+ 4. Enter connection settings for a new provider and press `Ctrl+S`. Then press `A` to add a model: discovery starts immediately and opens the upstream model list. Press `Esc` to cancel discovery or dismiss the list and enter an ID manually. You can also return and add models later.
193
105
 
194
106
  Saving updates and enables the model, but it does not force the current session to switch models.
195
107
 
@@ -201,9 +113,9 @@ Each provider can define:
201
113
  - API key and authorization-header behavior
202
114
  - Client-header identity
203
115
  - Provider-specific HTTP(S) proxy
204
- - One or more models
116
+ - Zero or more models
205
117
 
206
- When adding a model, the extension attempts to fetch the upstream model list. The complete discovery flow shares one 10-second limit and can be cancelled with `Esc`. Discovery uses the same API root and configured credentials as chat, and distinguishes authentication failures, missing endpoints, rate limits, and upstream errors. You can still enter a model ID manually after failure or cancellation.
118
+ Pressing `A` to add a model starts discovery automatically. Editing an existing model does not send a request automatically; choose Upstream model list to fetch on demand. The complete discovery flow shares one 10-second limit and can be cancelled with `Esc`. Discovery uses the same API root and configured credentials as chat, and distinguishes authentication failures, missing endpoints, rate limits, and upstream errors. Failure, empty results, or cancellation leave the add form open for manual ID entry. There is no automatic retry.
207
119
 
208
120
  Base URL represents the API root, to which the protocol endpoint is appended. For example, Anthropic with `https://gw.example.com/xxx` uses `/xxx/messages` for chat and `/xxx/models` for discovery. When entering a URL or switching protocols in the provider editor, a bare domain gets `/v1` for OpenAI / Anthropic or `/v1beta` for Gemini, including custom gateway domains. Gemini converts a final `/v1` path segment to `/v1beta`; switching from Gemini back to OpenAI / Anthropic converts a final `/v1beta` to `/v1`. The host, port, and path prefix are preserved, as are other explicit paths such as `/custom`, `/v1alpha`, and `/v2`.
209
121
 
@@ -251,21 +163,27 @@ Fast and Ultrafast require support from the upstream service, account, and model
251
163
 
252
164
  | Profile | Behavior |
253
165
  | --- | --- |
254
- | Recommended | Claude Code for Anthropic Messages, Codex for OpenAI Completions/Responses, and no identity headers for other protocols |
166
+ | Recommended | Claude Code for Anthropic Messages, Codex for OpenAI Completions/Responses, and Antigravity CLI for Google Gemini |
255
167
  | Disabled | Adds no extension-managed client identity headers |
256
168
  | Claude Code | Uses the built-in Claude Code compatibility headers and adds required Anthropic request metadata |
257
169
  | Codex | Uses the built-in Codex Rust CLI compatibility headers |
258
- | Custom | Uses a reusable JSON header set created in the header-profile panel |
170
+ | Antigravity CLI | Uses built-in Antigravity CLI identity headers with the existing Gemini endpoint and authentication |
171
+ | Custom | Uses a reusable name/value profile created in header management |
172
+
173
+ Built-in profiles live in `presets/builtin-client-headers.ts` and contain no authentication material. Selecting a built-in profile saves only the choice; requests use the plugin's definitions directly. Update the plugin and run `/reload` to use its latest fields. Claude Code's stable identity fields come from local captures of the real client. Codex's `codex_cli_rs` and Antigravity's `antigravity/cli` profiles follow [codex-proxy-rs](https://github.com/zyycn/codex-proxy-rs), with versions checked against the official stable npm release and Antigravity CLI release manifest respectively.
259
174
 
260
- Built-in profiles live in `presets/builtin-client-headers.ts` and contain no authentication material. Machine-local captures take precedence when present. Codex uses the `codex_cli_rs` identity, with fields based on [codex-proxy-rs](https://github.com/zyycn/codex-proxy-rs).
175
+ The Antigravity CLI profile supplies only its client-identity UA. It does not add OAuth, Cloud Code endpoints, or request-body wrappers. Gemini providers use it by default under Recommended; explicit Disabled or Custom selections keep their behavior.
261
176
 
262
177
  These headers only help API gateways that require a recognized client identity; they do not replace an API key. The public repository and npm package contain **no request-capture tooling, user captures, authentication headers, or machine-local state**. Disable identity headers or create a custom profile if a built-in profile does not fit your endpoint.
263
178
 
264
179
  Custom profiles reject authentication-related sensitive headers. Put authentication material in the provider's API-key setting instead.
265
180
 
181
+ The list always includes read-only ClaudeCode, Codex, and Antigravity CLI profiles; press `Enter` to inspect their fields and `C` to copy one into a custom profile. You can also create a custom profile and use `T` to apply a built-in template. The saved copy is independent and does not follow plugin updates.
182
+ Header management lists profile names, field counts, and referencing-provider counts, including providers with no models. Narrow layouts move IDs into the details. Press `N` to create a blank profile with an editable, generated ID. Press `A`, enter the header name, `Enter`, value, and `Enter`. Existing fields open directly on the value; `Tab` switches name/value. `D` only deletes the selected header field, `T` applies a template, and `J` opens bulk JSON. All paths edit the same draft; `Ctrl+S` saves it. Names are checked case-insensitively for conflicts; invalid input is retained with an error. Deleting a whole profile lists affected providers before reverting them to automatic headers.
183
+
266
184
  Explicit native headers override built-in templates; selecting a custom profile gives its values final priority. Header names are merged case-insensitively. Custom `anthropic-beta` lists are preserved in full, including when Adaptive Thinking is enabled.
267
185
 
268
- Generated-header snapshots follow the models actually rewritten; saving another model does not update an untouched model's snapshot. When no source record exists, only fields matching the current profile are recorded. Older values of uncertain origin remain native overrides and are not automatically removed by historical value or header name. **Disabled** therefore does not remove those overrides; inspect them before editing `models.json` manually.
186
+ Built-in identity headers are not copied into `models.json`; native paths without the extension do not receive them. Explicit user headers and custom profiles remain persisted. Migration removes a built-in field only when an existing source record proves ownership and its value has not been edited, and removes legacy capture caches. Untracked fields are preserved without guessing ownership from header names or current templates. Custom-profile copies retain source records so updates and deletion can synchronize them.
269
187
 
270
188
  ## Configuration files
271
189
 
@@ -280,7 +198,7 @@ Plugin configuration writes are serialized with a cross-process lock, and `enabl
280
198
 
281
199
  The configuration lock records both PID and system process start time to detect PID reuse; elapsed lock age never evicts an active owner. A failed identity query does not reclaim a potentially active lock, and writes cannot acquire a lock without verifying their own process identity. Queries use `pwsh` on Windows, `/proc` on Linux, and `/bin/ps` on macOS. The current process identity is cached within that process.
282
200
 
283
- Older endpoint configurations migrate to v5 metadata while preserving their final chat addresses. A pre-migration snapshot of both files is stored as `base-url-v5-*.json` in the extension configuration directory. These snapshots contain raw configuration and must be protected like credential files. A rollback requires restoring the matching code, `models.json`, and `state.json` together.
201
+ Older configurations migrate to v6 metadata, preserving final chat addresses and removing persisted built-in header copies. A pre-migration snapshot of both files is stored as `configuration-v6-*.json` in the extension configuration directory. These snapshots contain raw configuration and must be protected like credential files. A rollback requires restoring the matching code, `models.json`, and `state.json` together.
284
202
 
285
203
  ## Secrets and security
286
204
 
@@ -310,7 +228,7 @@ Additional considerations:
310
228
  | `@earendil-works/pi-tui` | `>=0.75.0` |
311
229
  | Runtime mode | `/model-manager` requires the Pi TUI |
312
230
 
313
- Pi `0.87.0` is the API floor for `agent_before_settle`, not a claim of compatibility verified across every release. Current real-host checks target Pi `1.5.2`; earlier releases have not been individually verified.
231
+ Pi `0.87.0` is the API floor for `agent_before_settle`, not a claim of compatibility verified across every release. Current real-host checks target Pi `1.7.0`; earlier releases have not been individually verified.
314
232
 
315
233
  The TUI copy defaults to Simplified Chinese; press `L` on the dashboard to switch to English.
316
234
 
@@ -325,7 +243,7 @@ pi -e .
325
243
 
326
244
  Pi loads the TypeScript entry point directly; no separate build step is required. Do not commit `state.json`, `bootstrap-meta.json`, `node_modules`, or request-capture data.
327
245
 
328
- Tests have separate stub and real-host entry points. The current real-host verification baseline is Pi `1.5.2`:
246
+ Tests have separate stub and real-host entry points. The current real-host verification baseline is Pi `1.7.0`:
329
247
 
330
248
  ```bash
331
249
  npm test
package/README.md CHANGED
@@ -10,118 +10,21 @@
10
10
 
11
11
  > 本扩展要求 Pi `>=0.87.0`,Node.js `22.x >=22.21.0` 或 `>=24.5.0`。Windows 配置锁需要 PowerShell 7(`pwsh`)。接入代理不支持 Bun。
12
12
 
13
- ## 界面预览
13
+ ## 操作窗口
14
14
 
15
- 下面的界面文本由真实组件渲染得出(终端宽 88 列)。实际使用时列宽会按当前数据收敛,选中行有背景色,各列状态按语义着色。
15
+ `/model-manager` 使用居中浮层,浏览、字段输入、选择和确认都在同一个窗口内完成。
16
16
 
17
- ```text
18
- ────────────────────────────────────────────────────────────────────────────────────────
19
- /model-manager
20
- 4 接入 · 5 模型 · 0 内置抓包 · 0 自定义请求头
21
-
22
- 接入 API 模型 请求头 代理 认证 状态
23
- ❯ OpenAI (openai) Responses 2 Auto→Codex direct env ready
24
- Claude (claude) Claude 1 ClaudeCode direct env ready
25
- Gemini (gemini) Gemini 1 Auto→不添加 direct env ready
26
- Local vLLM (local) Chat 1 Off proxy key ready
27
-
28
- ────────────────────────────────────────────────────────────────────────────────────────
29
- OpenAI (openai)
30
- endpoint https://api.openai.com/v1
31
- proxy direct
32
- api Responses · headers Auto→Codex · auth env
33
- models gpt-5.6-sol, gpt-5.6-terra
34
-
35
- ↑↓ 选择 Enter 进入 N 新建接入 D 删除接入 H 请求头 Esc 退出 / 搜索
36
- ────────────────────────────────────────────────────────────────────────────────────────
37
- ```
38
-
39
- <details>
40
- <summary>展开其余四个界面</summary>
41
-
42
- ### 接入内的模型列表
43
-
44
- ```text
45
- ────────────────────────────────────────────────────────────────────────────────────────
46
- /model-manager / OpenAI
47
- Responses · 2 模型 · headers Auto→Codex · proxy direct · auth env
48
- endpoint https://api.openai.com/v1
49
-
50
- 模型 ID 显示名 输入 Thinking 上下文
51
- ❯ gpt-5.6-sol 默认 文本,视觉 开 1.1M
52
- gpt-5.6-terra 默认 文本,视觉 开 1.1M
53
-
54
- ↑↓ 选择 Enter 编辑模型 A 添加模型 E 编辑接入 D 删除模型 Esc 返回 / 搜索
55
- ────────────────────────────────────────────────────────────────────────────────────────
56
- ```
57
-
58
- ### 接入配置
59
-
60
- ```text
61
- ────────────────────────────────────────────────────────────────────────────────────────
62
- 编辑接入 openai
63
- API Responses · 请求头 自动推荐(Auto→Codex)
64
- 接入 ID 必填,且不能与已有或 pi 内置接入重复
65
- Ctrl+S 保存并同步 models.json;不切换当前会话模型
66
-
67
- 接入 ID openai
68
- 显示名称 OpenAI
69
- API 协议 OpenAI Responses
70
- ❯ Base URL https://api.openai.com/v1
71
- 本机代理 关闭
72
- 代理地址 关闭时不使用
73
- API key $OPENAI_API_KEY
74
- 认证头 默认
75
- 请求头 自动推荐(Auto→Codex)
76
-
77
- ↑↓ 选择 ←→ 切换选项 Enter 编辑 Ctrl+S 保存并同步 Esc 返回
78
- ────────────────────────────────────────────────────────────────────────────────────────
79
- ```
17
+ | 区域 | 内容 |
18
+ | --- | --- |
19
+ | 顶部 | 当前页面路径与未保存标记 |
20
+ | 全宽列表 | 接入、模型或配置字段;始终只有一个操作列表 |
21
+ | 底部 | 当前项详情或操作结果,以及本页快捷键 |
80
22
 
81
- ### 模型能力
23
+ 窗口宽度最多 128 列、高度最多 32 行;短列表按内容收拢,长列表按可用高度滚动。首页表格按宽度展示接入 ID、名称、协议、模型数、认证方式、代理状态和地址,底部优先显示所选接入地址,`?` 可查看完整详情。窄屏收起次要列并缩短快捷键说明,矮屏压缩详情,不改变操作路径。调整终端大小保留草稿和搜索,不重新拉取模型。配色跟随 Pi 主题:整行背景标出当前项,标题、选中项及快捷键加粗,未保存、成功和错误分别使用语义色。实际字号由终端设置控制。
82
24
 
83
- ```text
84
- ────────────────────────────────────────────────────────────────────────────────────────
85
- 编辑模型 gpt-5.6-sol
86
- 接入 openai · API Responses
87
- Ctrl+S 保存并启用模型;不切换当前会话模型
88
-
89
- 模型 ID gpt-5.6-sol
90
- 重新拉取 上游模型列表
91
- 显示名称 默认 = 模型 ID
92
- ❯ 视觉支持 ◀ 开启 ▶
93
- Thinking ◀ 开启 ▶
94
- Fast mode ◀ 标准 ▶
95
- 上下文窗口 ◀ 1050000 ▶
96
- 最大输出 ◀ 128000 ▶
97
- 请求头 跟随接入(Auto→Codex)
98
-
99
- ↑↓ 选择 ←→ 切换选项 Enter 编辑 Ctrl+S 保存并启用 Esc 返回
100
- ────────────────────────────────────────────────────────────────────────────────────────
101
- ```
25
+ 接入设置按“基础连接/认证与请求头/传输与兼容”分组。左右键调整枚举、开关和数值预设;文本通过原生 Input 在原行编辑,请求头 JSON 使用同窗原生多行 Editor。新建接入时,Base URL 按 `Enter` 后从空白输入开始;编辑已保存接入时保留原地址。取消输入不改动草稿。API key 默认脱敏,在该行按 `←` / `→` 切换显示/隐藏,离开编辑页后重新隐藏;显示的是保存的配置值,不解析环境变量或执行命令。`Enter` 输入新值替换,留空保留;清除密钥使用独立字段操作。代理地址编辑从空白开始,留空保留,不回显已保存的代理凭据。
102
26
 
103
- ### 模型发现
104
-
105
- ```text
106
- ────────────────────────────────────────────────────────────────────────────────────────
107
- 选择模型(openai)
108
- 搜索: <直接输入搜索>
109
- 匹配 9 / 9 · 页码 1 / 2
110
-
111
- gpt-5.3
112
- gpt-5.4
113
- gpt-5.4-mini
114
- gpt-5.5
115
- gpt-5.6-luna
116
- ❯ gpt-5.6-sol ● 当前
117
- gpt-5.6-terra
118
- gpt-image-2
119
-
120
- ↑↓ 选择 · ←→/PgUp/PgDn 翻页 · 输入搜索 · Backspace 删除 · Enter 确认 · Esc 取消
121
- ────────────────────────────────────────────────────────────────────────────────────────
122
- ```
123
-
124
- </details>
27
+ 保存后留在当前字段。落盘成功但 registry 或 runtime 刷新失败时,明确提示已保存及刷新警告,草稿仍转为已保存状态,可继续编辑或执行 `/reload` 重试激活。离开有修改的对象时可选择“保存并继续/放弃修改/继续编辑”。接入独立保存,不要求先配置模型;拉取失败、返回空列表或删除最后一个模型,都不会删除已保存的接入。
125
28
 
126
29
  ## 功能
127
30
 
@@ -132,9 +35,10 @@ Ctrl+S 保存并启用模型;不切换当前会话模型
132
35
  - 从兼容上游拉取模型 ID,也可手动填写模型。
133
36
  - 配置上下文窗口、最大输出、视觉支持和 Thinking。
134
37
  - 支持 Anthropic Adaptive Thinking 与 Legacy Thinking。
38
+ - 所有协议统一开放 `minimal / low / medium / high / xhigh / max`,按用户选择的同名档位发送(协议需要时调整大小写);不按模型 ID 或已有 `thinkingLevelMap` 限制,是否支持由上游判断。
135
39
  - 为 OpenAI Responses 模型选择标准、Fast(`priority`)或 Ultrafast(`ultrafast`)速度档位。
136
40
  - 为每个接入单独配置直连或 HTTP(S) 代理。
137
- - 提供自动推荐、禁用、Claude Code、Codex 和自定义请求头模式。
41
+ - 提供自动推荐、禁用、Claude Code、Codex、Antigravity CLI 和自定义请求头模式。
138
42
  - API key 支持字面值、`$ENV_VAR` / `${ENV_VAR}` 和 Pi 的 `!command` 引用。
139
43
  - 使用跨进程锁与可恢复双文件事务持久化配置,并在保存后重新注册受管理的 Provider。
140
44
 
@@ -175,21 +79,29 @@ pi install npm:pi-model-manager
175
79
  /model-manager
176
80
  ```
177
81
 
178
- 3. 在主面板中管理接入:
82
+ 3. 使用方向键和当前页面的快捷键操作:
179
83
 
180
84
  | 按键 | 操作 |
181
85
  | --- | --- |
182
- | `Enter` | 进入所选接入并管理模型 |
183
- | `N` | 新建接入及其第一个模型 |
184
- | `D` | 删除所选接入 |
185
- | `H` | 管理可复用请求头 |
186
- | `L` | 切换界面语言(简体中文 / English),选择后立即生效并持久保存 |
187
- | `/` | 搜索当前列表;`Tab` 退出输入但保留过滤,`Esc` 清空 |
188
- | `Esc` | 返回或退出 |
189
-
190
- 单字母快捷键不区分大小写;底部提示按终端宽度折行,窄终端下也不会丢失。
191
-
192
- 4. 在编辑器中使用 `↑` / `↓` 选择字段,按 `Enter` 编辑;开关类字段可用 `←` / `→` 就地切换;按 `Ctrl+S` 保存。
86
+ | `↑` / `↓` | 选择接入、模型、字段或选项 |
87
+ | `←` / `→` | 调整枚举、开关或数值预设;API key 行切换显隐;输入时只移动光标 |
88
+ | `Tab` | 搜索中切换输入/列表;请求头行编辑中切换名称/值 |
89
+ | `Enter` | 进入、编辑或确认;添加请求头时先从名称进入值,再完成该行 |
90
+ | `Ctrl+S` | 校验并保存当前对象,留在原位 |
91
+ | `Ctrl+Enter` | 完成多行 JSON 编辑,写入对象草稿 |
92
+ | `/` | 进入当前列表的搜索输入 |
93
+ | `PgUp` / `PgDn` | 按可见行翻页;长确认信息中滚动说明 |
94
+ | `?` | 查看完整字段说明或结果信息 |
95
+ | `Esc` | 取消字段;搜索中清空过滤;否则返回上一页,主列表中退出 |
96
+ | `N` / `D` / `H` / `L` | 接入列表:新建/删除接入/请求头库/直接选择语言 |
97
+ | `A` / `E` / `D` | 模型列表:添加模型/编辑接入/删除模型 |
98
+ | `N` / `D` | 请求头列表:新建/删除自定义方案;内置方案按 `Enter` 查看 |
99
+ | `C` | 内置请求头详情:复制为自定义方案 |
100
+ | `A` / `D` / `T` / `J` | 请求头编辑:添加字段/删除当前字段/套用模板/批量 JSON |
101
+
102
+ 字母快捷键不区分大小写,输入文本或搜索时仅作为普通字符。`Home` / `End` 跳到列表首尾,输入时仍移动光标。保存过的接入表单也可按 `A` 添加模型。
103
+
104
+ 4. 新建接入时填写连接配置,按 `Ctrl+S` 保存。随后按 `A` 添加模型,会自动拉取并打开上游模型列表;按 `Esc` 可取消拉取或退出选择,回到表单手填 ID,也可以返回后稍后再添加。
193
105
 
194
106
  保存会更新并启用模型,但不会强制切换当前会话正在使用的模型。
195
107
 
@@ -203,9 +115,9 @@ pi install npm:pi-model-manager
203
115
  - API key 与认证头行为
204
116
  - 请求头身份
205
117
  - 接入级 HTTP(S) 代理
206
- - 一个或多个模型
118
+ - 零个或多个模型
207
119
 
208
- 新建模型时,扩展会尝试从上游读取模型列表;整次发现共用一个 10 秒上限,可按 `Esc` 手动取消。列表与聊天使用同一 API 根地址和配置的认证信息,错误会区分认证失败、接口不存在、限流和上游异常。失败或取消后仍可手动输入模型 ID。
120
+ 按 `A` 添加模型时自动拉取;编辑已有模型时不自动请求,仍可选择“上游模型列表”主动拉取。整次发现共用一个 10 秒上限,可按 `Esc` 手动取消。列表与聊天使用同一 API 根地址和配置的认证信息,错误会区分认证失败、接口不存在、限流和上游异常。失败、空结果或取消后留在添加表单,仍可手动输入模型 ID;不会自动重试。
209
121
 
210
122
  Base URL 表示 API 根地址,再追加协议端点。例如 Anthropic 的 `https://gw.example.com/xxx` 请求 `/xxx/messages`,模型列表请求 `/xxx/models`。在接入编辑器中输入地址或切换协议时,只填域名会按协议补 `/v1`(OpenAI / Anthropic)或 `/v1beta`(Gemini,包括自定义中转域名)。Gemini 会将末尾完整路径段 `/v1` 转为 `/v1beta`;从 Gemini 切回 OpenAI / Anthropic 时,末尾 `/v1beta` 转为 `/v1`。域名、端口和路径前缀保留,其他显式路径(如 `/custom`、`/v1alpha`、`/v2`)不改写。
211
123
 
@@ -255,21 +167,27 @@ Fast 和 Ultrafast 需要上游、账号及模型支持,可能产生额外费
255
167
 
256
168
  | 模式 | 行为 |
257
169
  | --- | --- |
258
- | 自动推荐 | Anthropic Messages 使用 Claude Code;OpenAI Completions/Responses 使用 Codex;其他协议不附加身份头 |
170
+ | 自动推荐 | Anthropic Messages 使用 Claude Code;OpenAI Completions/Responses 使用 Codex;Google Gemini 使用 Antigravity CLI |
259
171
  | 不添加 | 不添加扩展管理的客户端身份请求头 |
260
172
  | Claude Code | 使用内置 Claude Code 兼容请求头,并为 Anthropic 请求补充必要的兼容 metadata |
261
173
  | Codex | 使用内置 Codex Rust CLI 兼容请求头 |
262
- | 自定义 | 使用在请求头面板中创建的可复用 JSON 请求头集合 |
174
+ | Antigravity CLI | 使用内置 Antigravity CLI 身份请求头,保留当前 Gemini 接口与认证配置 |
175
+ | 自定义 | 使用在请求头管理中创建的可复用名称/值方案 |
176
+
177
+ 内置画像位于 `presets/builtin-client-headers.ts`,不包含认证信息。选择内置时仅保存所选方案,发送请求时直接使用插件定义;更新插件并 `/reload` 即使用新版字段。Claude Code 的稳定身份字段来自真实客户端本地捕获;Codex 的 `codex_cli_rs` 与 Antigravity 的 `antigravity/cli` 画像以 [codex-proxy-rs](https://github.com/zyycn/codex-proxy-rs) 为参考,版本分别核对官方 npm 稳定版与 Antigravity CLI 发布清单。
263
178
 
264
- 内置画像位于 `presets/builtin-client-headers.ts`,不包含认证信息;本机抓包缓存存在时优先使用缓存。Codex 使用 `codex_cli_rs` 画像,字段以 [codex-proxy-rs](https://github.com/zyycn/codex-proxy-rs) 为参考。
179
+ Antigravity CLI 方案仅提供客户端身份 UA,不接入其 OAuth、Cloud Code 专用端点或请求体封装。Gemini 接入选择“自动推荐”时默认使用该方案;显式选择“不添加”或自定义方案时仍按原选择生效。
265
180
 
266
181
  这些值只用于兼容需要识别客户端身份的 API 中转,不代替 API key。公开仓库和 npm 包**不包含请求捕获工具、用户抓包、认证头或本机状态**。如果内置值不适合你的服务,请关闭身份头或创建自定义请求头。
267
182
 
268
183
  自定义请求头会拒绝认证类敏感字段;认证信息应放在接入的 API key 配置中。
269
184
 
185
+ 管理页常驻显示只读的 ClaudeCode、Codex 和 Antigravity CLI,按 `Enter` 查看字段,按 `C` 复制为自定义方案。也可新建自定义方案后用 `T` 套用内置模板。复制后保存为独立内容,不跟随插件更新。
186
+ 请求头管理以方案名称为主列,显示字段数与引用接入数(包括零模型接入);窄屏将 ID 移到详情。按 `N` 新建空白方案,ID 自动生成且可修改。按 `A` 后依次输入请求头名称、`Enter`、值、`Enter`;已有字段按 `Enter` 编辑值,`Tab` 切换名称和值。`D` 仅删除选中的请求头字段,`T` 套用模板,`J` 编辑完整 JSON,所有操作先修改同一份草稿,`Ctrl+S` 保存。名称按大小写不敏感检查冲突,非法字段保留输入并显示错误。删除整套方案前列出受影响接入,确认后恢复自动推荐。
187
+
270
188
  显式原生请求头覆盖内置模板;选择自定义请求头时,自定义值拥有最终优先级。同名字段按大小写不敏感方式合并。自定义 `anthropic-beta` 清单完整保留,Adaptive Thinking 不会修改它。
271
189
 
272
- 生成头来源快照与实际写入的模型同步;只保存其他模型不会更新未改写模型的快照。缺少来源记录时,只记录与当前画像同值的字段,无法确认来源的旧值作为原生覆盖保留,不按历史值或头名自动清理。因此「不添加」不会删除这类旧覆盖,如需移除须核对后手动编辑 `models.json`。
190
+ `models.json` 不保存内置身份头副本;不加载扩展时,原生读取路径不会获得这些内置头。用户显式头和自定义方案仍持久保存。迁移只删除已有来源记录且值未被用户改写的内置字段,并移除旧抓包缓存;没有来源证据的字段保留,不根据头名或当前模板猜测归属。自定义方案的生成副本继续记录来源,以便方案更新或删除时同步。
273
191
 
274
192
  ## 配置文件
275
193
 
@@ -284,7 +202,7 @@ Fast 和 Ultrafast 需要上游、账号及模型支持,可能产生额外费
284
202
 
285
203
  配置锁记录 PID 和系统进程创建时间,以识别 PID 复用;不会按持锁时长强行回收。查询失败时不抢占可能活跃的锁,自身身份无法确认时拒绝持锁写入。Windows 使用 `pwsh`,Linux 使用 `/proc`,macOS 使用 `/bin/ps`;当前进程的身份在进程内缓存。
286
204
 
287
- 旧端点配置会升级到 v5 元数据,保持原最终聊天地址,迁移前的双文件快照保存在插件配置目录的 `base-url-v5-*.json`。快照包含原始配置,应按凭据文件保护;回退时需配套恢复代码、`models.json` 和 `state.json`。
205
+ 旧配置会升级到 v6 元数据,保持原最终聊天地址并清理内置头副本。迁移前的双文件快照保存在插件配置目录的 `configuration-v6-*.json`。快照包含原始配置,应按凭据文件保护;回退时需配套恢复代码、`models.json` 和 `state.json`。
288
206
 
289
207
  ## 密钥与安全
290
208
 
@@ -314,7 +232,7 @@ ${ANTHROPIC_API_KEY}
314
232
  | `@earendil-works/pi-tui` | `>=0.75.0` |
315
233
  | 运行模式 | `/model-manager` 需要 Pi TUI |
316
234
 
317
- Pi `0.87.0` 是 `agent_before_settle` 的 API 下限,不代表已逐版本验证兼容性;当前真实宿主检查基线为 Pi `1.5.2`,更早版本未逐一验证。
235
+ Pi `0.87.0` 是 `agent_before_settle` 的 API 下限,不代表已逐版本验证兼容性;当前真实宿主检查基线为 Pi `1.7.0`,更早版本未逐一验证。
318
236
 
319
237
  默认 TUI 文案为简体中文;可在主面板按 `L` 切换为 English。
320
238
 
@@ -329,7 +247,7 @@ pi -e .
329
247
 
330
248
  扩展由 Pi 直接加载 TypeScript 入口,不需要单独构建步骤。开发时请勿提交 `state.json`、`bootstrap-meta.json`、`node_modules` 或任何请求捕获数据。
331
249
 
332
- 测试分为替身测试和真实宿主测试,当前真实宿主验证基线为 Pi `1.5.2`:
250
+ 测试分为替身测试和真实宿主测试,当前真实宿主验证基线为 Pi `1.7.0`:
333
251
 
334
252
  ```bash
335
253
  npm test
package/common.ts CHANGED
@@ -32,13 +32,16 @@ export function hasStringRecordEntries(record: Record<string, string> | undefine
32
32
  export function parseStringRecordJson(source: string, label: string): Record<string, string> {
33
33
  const parsed = JSON.parse(stripJsonNoise(source));
34
34
  if (!isObjectRecord(parsed)) throw new Error(t("{label} JSON 必须是对象", { label }));
35
- const record: Record<string, string> = {};
35
+ const entries: [string, string][] = [];
36
+ const names = new Set<string>();
36
37
  for (const [key, value] of Object.entries(parsed)) {
37
38
  if (typeof value !== "string") throw new Error(t("{label} {key} 的值必须是字符串", { label, key }));
38
39
  const trimmedKey = key.trim();
39
- if (trimmedKey) record[trimmedKey] = value;
40
+ if (names.has(trimmedKey)) throw new Error(t("{label} 名称重复:{key}", { label, key: trimmedKey }));
41
+ names.add(trimmedKey);
42
+ entries.push([trimmedKey, value]);
40
43
  }
41
- return record;
44
+ return Object.fromEntries(entries);
42
45
  }
43
46
 
44
47
  export function stringifyJson(value: unknown): string {