pi-model-manager 0.4.9 → 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 +47 -130
- package/README.md +47 -130
- package/common.ts +6 -3
- package/configuration-persistence.ts +39 -52
- package/header-profile-mutations.ts +13 -38
- package/i18n.ts +11 -130
- package/index.ts +13 -11
- package/model-mutations.ts +75 -125
- package/model-request-headers.ts +54 -0
- package/models-json-sync.ts +13 -13
- package/package.json +2 -1
- package/presets/builtin-client-headers.ts +9 -4
- package/presets/client-headers.ts +9 -18
- package/presets/providers.ts +0 -10
- package/presets/thinking.ts +5 -69
- package/provider-registrar.ts +11 -59
- package/provider-transport.ts +5 -7
- package/request-pipeline.ts +10 -0
- package/rescue.ts +10 -16
- package/state-document.ts +26 -32
- package/state-metadata-store.ts +23 -58
- package/state-store.ts +8 -16
- package/tui/model-list-fetch.ts +2 -6
- package/tui/model-search.ts +45 -0
- package/tui/model-values.ts +24 -0
- package/tui/ui-helpers.ts +68 -157
- package/tui/workbench-fields.ts +127 -0
- package/tui/workbench-headers.ts +80 -0
- package/tui/workbench-types.ts +67 -0
- package/tui/workbench-window.ts +439 -0
- package/tui/workbench.ts +385 -0
- package/types.ts +9 -14
- package/tui/dashboard.ts +0 -463
- package/tui/editor-model.ts +0 -391
- package/tui/editor-provider.ts +0 -368
- package/tui/header-profiles-panel.ts +0 -407
- package/tui/model-picker.ts +0 -273
- package/tui/persistent-menu.ts +0 -590
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
|
-
##
|
|
13
|
+
## Management window
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
`/model-manager` opens a centered overlay. Browsing, editing, selection, and confirmation stay in the same window.
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,10 +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.
|
|
135
|
-
-
|
|
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.
|
|
136
39
|
- Select Standard, Fast (`priority`), or Ultrafast (`ultrafast`) service tiers per OpenAI Responses model.
|
|
137
40
|
- Route each provider directly or through its own HTTP(S) proxy.
|
|
138
|
-
- 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.
|
|
139
42
|
- Reference API keys as literals, `$ENV_VAR` / `${ENV_VAR}`, or Pi `!command` values.
|
|
140
43
|
- Persist configuration with a cross-process lock and recoverable two-file transactions, then re-register managed providers after saving.
|
|
141
44
|
|
|
@@ -176,21 +79,29 @@ pi install npm:pi-model-manager
|
|
|
176
79
|
/model-manager
|
|
177
80
|
```
|
|
178
81
|
|
|
179
|
-
3.
|
|
82
|
+
3. Navigate with arrows and page-specific shortcuts:
|
|
180
83
|
|
|
181
84
|
| Key | Action |
|
|
182
85
|
| --- | --- |
|
|
183
|
-
|
|
|
184
|
-
|
|
|
185
|
-
| `
|
|
186
|
-
| `
|
|
187
|
-
| `
|
|
188
|
-
|
|
|
189
|
-
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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.
|
|
194
105
|
|
|
195
106
|
Saving updates and enables the model, but it does not force the current session to switch models.
|
|
196
107
|
|
|
@@ -202,9 +113,9 @@ Each provider can define:
|
|
|
202
113
|
- API key and authorization-header behavior
|
|
203
114
|
- Client-header identity
|
|
204
115
|
- Provider-specific HTTP(S) proxy
|
|
205
|
-
-
|
|
116
|
+
- Zero or more models
|
|
206
117
|
|
|
207
|
-
|
|
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.
|
|
208
119
|
|
|
209
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`.
|
|
210
121
|
|
|
@@ -252,21 +163,27 @@ Fast and Ultrafast require support from the upstream service, account, and model
|
|
|
252
163
|
|
|
253
164
|
| Profile | Behavior |
|
|
254
165
|
| --- | --- |
|
|
255
|
-
| Recommended | Claude Code for Anthropic Messages, Codex for OpenAI Completions/Responses, and
|
|
166
|
+
| Recommended | Claude Code for Anthropic Messages, Codex for OpenAI Completions/Responses, and Antigravity CLI for Google Gemini |
|
|
256
167
|
| Disabled | Adds no extension-managed client identity headers |
|
|
257
168
|
| Claude Code | Uses the built-in Claude Code compatibility headers and adds required Anthropic request metadata |
|
|
258
169
|
| Codex | Uses the built-in Codex Rust CLI compatibility headers |
|
|
259
|
-
|
|
|
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.
|
|
260
174
|
|
|
261
|
-
|
|
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.
|
|
262
176
|
|
|
263
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.
|
|
264
178
|
|
|
265
179
|
Custom profiles reject authentication-related sensitive headers. Put authentication material in the provider's API-key setting instead.
|
|
266
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
|
+
|
|
267
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.
|
|
268
185
|
|
|
269
|
-
|
|
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.
|
|
270
187
|
|
|
271
188
|
## Configuration files
|
|
272
189
|
|
|
@@ -281,7 +198,7 @@ Plugin configuration writes are serialized with a cross-process lock, and `enabl
|
|
|
281
198
|
|
|
282
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.
|
|
283
200
|
|
|
284
|
-
Older
|
|
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.
|
|
285
202
|
|
|
286
203
|
## Secrets and security
|
|
287
204
|
|
|
@@ -311,7 +228,7 @@ Additional considerations:
|
|
|
311
228
|
| `@earendil-works/pi-tui` | `>=0.75.0` |
|
|
312
229
|
| Runtime mode | `/model-manager` requires the Pi TUI |
|
|
313
230
|
|
|
314
|
-
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.
|
|
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.
|
|
315
232
|
|
|
316
233
|
The TUI copy defaults to Simplified Chinese; press `L` on the dashboard to switch to English.
|
|
317
234
|
|
|
@@ -326,7 +243,7 @@ pi -e .
|
|
|
326
243
|
|
|
327
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.
|
|
328
245
|
|
|
329
|
-
Tests have separate stub and real-host entry points. The current real-host verification baseline is Pi `1.
|
|
246
|
+
Tests have separate stub and real-host entry points. The current real-host verification baseline is Pi `1.7.0`:
|
|
330
247
|
|
|
331
248
|
```bash
|
|
332
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
|
-
|
|
15
|
+
`/model-manager` 使用居中浮层,浏览、字段输入、选择和确认都在同一个窗口内完成。
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
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,10 +35,10 @@ Ctrl+S 保存并启用模型;不切换当前会话模型
|
|
|
132
35
|
- 从兼容上游拉取模型 ID,也可手动填写模型。
|
|
133
36
|
- 配置上下文窗口、最大输出、视觉支持和 Thinking。
|
|
134
37
|
- 支持 Anthropic Adaptive Thinking 与 Legacy Thinking。
|
|
135
|
-
-
|
|
38
|
+
- 所有协议统一开放 `minimal / low / medium / high / xhigh / max`,按用户选择的同名档位发送(协议需要时调整大小写);不按模型 ID 或已有 `thinkingLevelMap` 限制,是否支持由上游判断。
|
|
136
39
|
- 为 OpenAI Responses 模型选择标准、Fast(`priority`)或 Ultrafast(`ultrafast`)速度档位。
|
|
137
40
|
- 为每个接入单独配置直连或 HTTP(S) 代理。
|
|
138
|
-
- 提供自动推荐、禁用、Claude Code、Codex 和自定义请求头模式。
|
|
41
|
+
- 提供自动推荐、禁用、Claude Code、Codex、Antigravity CLI 和自定义请求头模式。
|
|
139
42
|
- API key 支持字面值、`$ENV_VAR` / `${ENV_VAR}` 和 Pi 的 `!command` 引用。
|
|
140
43
|
- 使用跨进程锁与可恢复双文件事务持久化配置,并在保存后重新注册受管理的 Provider。
|
|
141
44
|
|
|
@@ -176,21 +79,29 @@ pi install npm:pi-model-manager
|
|
|
176
79
|
/model-manager
|
|
177
80
|
```
|
|
178
81
|
|
|
179
|
-
3.
|
|
82
|
+
3. 使用方向键和当前页面的快捷键操作:
|
|
180
83
|
|
|
181
84
|
| 按键 | 操作 |
|
|
182
85
|
| --- | --- |
|
|
183
|
-
|
|
|
184
|
-
|
|
|
185
|
-
| `
|
|
186
|
-
| `
|
|
187
|
-
| `
|
|
188
|
-
|
|
|
189
|
-
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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,也可以返回后稍后再添加。
|
|
194
105
|
|
|
195
106
|
保存会更新并启用模型,但不会强制切换当前会话正在使用的模型。
|
|
196
107
|
|
|
@@ -204,9 +115,9 @@ pi install npm:pi-model-manager
|
|
|
204
115
|
- API key 与认证头行为
|
|
205
116
|
- 请求头身份
|
|
206
117
|
- 接入级 HTTP(S) 代理
|
|
207
|
-
-
|
|
118
|
+
- 零个或多个模型
|
|
208
119
|
|
|
209
|
-
|
|
120
|
+
按 `A` 添加模型时自动拉取;编辑已有模型时不自动请求,仍可选择“上游模型列表”主动拉取。整次发现共用一个 10 秒上限,可按 `Esc` 手动取消。列表与聊天使用同一 API 根地址和配置的认证信息,错误会区分认证失败、接口不存在、限流和上游异常。失败、空结果或取消后留在添加表单,仍可手动输入模型 ID;不会自动重试。
|
|
210
121
|
|
|
211
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`)不改写。
|
|
212
123
|
|
|
@@ -256,21 +167,27 @@ Fast 和 Ultrafast 需要上游、账号及模型支持,可能产生额外费
|
|
|
256
167
|
|
|
257
168
|
| 模式 | 行为 |
|
|
258
169
|
| --- | --- |
|
|
259
|
-
| 自动推荐 | Anthropic Messages 使用 Claude Code;OpenAI Completions/Responses 使用 Codex
|
|
170
|
+
| 自动推荐 | Anthropic Messages 使用 Claude Code;OpenAI Completions/Responses 使用 Codex;Google Gemini 使用 Antigravity CLI |
|
|
260
171
|
| 不添加 | 不添加扩展管理的客户端身份请求头 |
|
|
261
172
|
| Claude Code | 使用内置 Claude Code 兼容请求头,并为 Anthropic 请求补充必要的兼容 metadata |
|
|
262
173
|
| Codex | 使用内置 Codex Rust CLI 兼容请求头 |
|
|
263
|
-
|
|
|
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 发布清单。
|
|
264
178
|
|
|
265
|
-
|
|
179
|
+
Antigravity CLI 方案仅提供客户端身份 UA,不接入其 OAuth、Cloud Code 专用端点或请求体封装。Gemini 接入选择“自动推荐”时默认使用该方案;显式选择“不添加”或自定义方案时仍按原选择生效。
|
|
266
180
|
|
|
267
181
|
这些值只用于兼容需要识别客户端身份的 API 中转,不代替 API key。公开仓库和 npm 包**不包含请求捕获工具、用户抓包、认证头或本机状态**。如果内置值不适合你的服务,请关闭身份头或创建自定义请求头。
|
|
268
182
|
|
|
269
183
|
自定义请求头会拒绝认证类敏感字段;认证信息应放在接入的 API key 配置中。
|
|
270
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
|
+
|
|
271
188
|
显式原生请求头覆盖内置模板;选择自定义请求头时,自定义值拥有最终优先级。同名字段按大小写不敏感方式合并。自定义 `anthropic-beta` 清单完整保留,Adaptive Thinking 不会修改它。
|
|
272
189
|
|
|
273
|
-
|
|
190
|
+
`models.json` 不保存内置身份头副本;不加载扩展时,原生读取路径不会获得这些内置头。用户显式头和自定义方案仍持久保存。迁移只删除已有来源记录且值未被用户改写的内置字段,并移除旧抓包缓存;没有来源证据的字段保留,不根据头名或当前模板猜测归属。自定义方案的生成副本继续记录来源,以便方案更新或删除时同步。
|
|
274
191
|
|
|
275
192
|
## 配置文件
|
|
276
193
|
|
|
@@ -285,7 +202,7 @@ Fast 和 Ultrafast 需要上游、账号及模型支持,可能产生额外费
|
|
|
285
202
|
|
|
286
203
|
配置锁记录 PID 和系统进程创建时间,以识别 PID 复用;不会按持锁时长强行回收。查询失败时不抢占可能活跃的锁,自身身份无法确认时拒绝持锁写入。Windows 使用 `pwsh`,Linux 使用 `/proc`,macOS 使用 `/bin/ps`;当前进程的身份在进程内缓存。
|
|
287
204
|
|
|
288
|
-
|
|
205
|
+
旧配置会升级到 v6 元数据,保持原最终聊天地址并清理内置头副本。迁移前的双文件快照保存在插件配置目录的 `configuration-v6-*.json`。快照包含原始配置,应按凭据文件保护;回退时需配套恢复代码、`models.json` 和 `state.json`。
|
|
289
206
|
|
|
290
207
|
## 密钥与安全
|
|
291
208
|
|
|
@@ -315,7 +232,7 @@ ${ANTHROPIC_API_KEY}
|
|
|
315
232
|
| `@earendil-works/pi-tui` | `>=0.75.0` |
|
|
316
233
|
| 运行模式 | `/model-manager` 需要 Pi TUI |
|
|
317
234
|
|
|
318
|
-
Pi `0.87.0` 是 `agent_before_settle` 的 API 下限,不代表已逐版本验证兼容性;当前真实宿主检查基线为 Pi `1.
|
|
235
|
+
Pi `0.87.0` 是 `agent_before_settle` 的 API 下限,不代表已逐版本验证兼容性;当前真实宿主检查基线为 Pi `1.7.0`,更早版本未逐一验证。
|
|
319
236
|
|
|
320
237
|
默认 TUI 文案为简体中文;可在主面板按 `L` 切换为 English。
|
|
321
238
|
|
|
@@ -330,7 +247,7 @@ pi -e .
|
|
|
330
247
|
|
|
331
248
|
扩展由 Pi 直接加载 TypeScript 入口,不需要单独构建步骤。开发时请勿提交 `state.json`、`bootstrap-meta.json`、`node_modules` 或任何请求捕获数据。
|
|
332
249
|
|
|
333
|
-
测试分为替身测试和真实宿主测试,当前真实宿主验证基线为 Pi `1.
|
|
250
|
+
测试分为替身测试和真实宿主测试,当前真实宿主验证基线为 Pi `1.7.0`:
|
|
334
251
|
|
|
335
252
|
```bash
|
|
336
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
|
|
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)
|
|
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
|
|
44
|
+
return Object.fromEntries(entries);
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
export function stringifyJson(value: unknown): string {
|