pi-model-manager 0.3.1 → 0.3.3

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
@@ -4,11 +4,11 @@ English · [简体中文](./README.md)
4
4
 
5
5
  [![Pi](https://img.shields.io/badge/Pi-%3E%3D0.84.2-6f42c1)](https://github.com/earendil-works/pi)
6
6
  [![License](https://img.shields.io/badge/license-AGPL--3.0-blue.svg)](./LICENSE)
7
- [![Version](https://img.shields.io/badge/version-0.3.1-2f81f7.svg)](https://github.com/Qihuanxishini/pi-model-manager)
7
+ [![Version](https://img.shields.io/badge/version-0.3.2-2f81f7.svg)](https://github.com/Qihuanxishini/pi-model-manager)
8
8
 
9
9
  A TUI model and provider manager for [Pi](https://github.com/earendil-works/pi). It keeps Pi's native `models.json` as the single source of truth for model configuration while adding provider/model editing, client-header identities, proxy routing, and protocol compatibility controls.
10
10
 
11
- > The current stable version is `0.3.1` and requires Pi `>=0.84.2`.
11
+ > The current stable version is `0.3.2` and requires Pi `>=0.84.2`.
12
12
 
13
13
  ## Interface preview
14
14
 
@@ -30,7 +30,7 @@ OpenAI (openai)
30
30
  endpoint https://api.openai.com/v1
31
31
  proxy direct
32
32
  api Responses · headers Auto→Codex · auth env
33
- models gpt-5.1, gpt-5.1-mini
33
+ models gpt-5.6-sol, gpt-5.6-terra
34
34
 
35
35
  ↑↓ 选择 Enter 进入 N 新建接入 D 删除接入 H 请求头 Esc 退出 / 搜索
36
36
  ────────────────────────────────────────────────────────────────────────────────────────
@@ -48,8 +48,8 @@ Responses · 2 模型 · headers Auto→Codex · proxy direct · auth env
48
48
  endpoint https://api.openai.com/v1
49
49
 
50
50
  模型 ID 显示名 输入 Thinking 上下文
51
- ❯ gpt-5.1 默认 文本,视觉 开 400K
52
- gpt-5.1-mini 默认 文本,视觉 开 400K
51
+ ❯ gpt-5.6-sol 默认 文本,视觉 开 1.1M
52
+ gpt-5.6-terra 默认 文本,视觉 开 1.1M
53
53
 
54
54
  ↑↓ 选择 Enter 编辑模型 A 添加模型 E 编辑接入 D 删除模型 Esc 返回 / 搜索
55
55
  ────────────────────────────────────────────────────────────────────────────────────────
@@ -82,17 +82,17 @@ Ctrl+S 保存并同步 models.json;不切换当前会话模型
82
82
 
83
83
  ```text
84
84
  ────────────────────────────────────────────────────────────────────────────────────────
85
- 编辑模型 gpt-5.1
85
+ 编辑模型 gpt-5.6-sol
86
86
  接入 openai · API Responses
87
87
  Ctrl+S 保存并启用模型;不切换当前会话模型
88
88
 
89
- 模型 ID gpt-5.1
89
+ 模型 ID gpt-5.6-sol
90
90
  重新拉取 上游模型列表
91
91
  显示名称 默认 = 模型 ID
92
92
  ❯ 视觉支持 开启
93
93
  Thinking 开启
94
94
  Fast mode 关闭
95
- 上下文窗口 400000
95
+ 上下文窗口 1050000
96
96
  最大输出 128000
97
97
  请求头 跟随接入(Auto→Codex)
98
98
 
@@ -108,14 +108,14 @@ Ctrl+S 保存并启用模型;不切换当前会话模型
108
108
  搜索: <直接输入搜索>
109
109
  匹配 9 / 9 · 页码 1 / 2
110
110
 
111
- dall-e-3
112
- gpt-4.1
113
- gpt-4.1-mini
114
- ❯ gpt-5.1 ← 当前
115
- gpt-5.1-codex
116
- gpt-5.1-mini
117
- o4-mini
118
- text-embedding-3-large
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
119
 
120
120
  ↑↓ 选择 · ←→/PgUp/PgDn 翻页 · 输入搜索 · Backspace 删除 · Enter 确认 · Esc 取消
121
121
  ────────────────────────────────────────────────────────────────────────────────────────
@@ -227,8 +227,8 @@ Model capabilities include:
227
227
 
228
228
  The current built-in values were derived from real client requests with authentication fields removed:
229
229
 
230
- - Claude Code `2.1.232`
231
- - Codex TUI `0.147.0`
230
+ - Claude Code `2.1.243`
231
+ - Codex TUI `0.149.1`
232
232
 
233
233
  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.
234
234
 
@@ -295,9 +295,9 @@ npm pack --dry-run
295
295
 
296
296
  Open a reproducible report in [GitHub Issues](https://github.com/Qihuanxishini/pi-model-manager/issues). Remove API keys, authentication headers, proxy credentials, and private endpoints before sharing configuration or logs.
297
297
 
298
- ## Acknowledgements
298
+ ## Friendly links
299
299
 
300
- Thanks to the [LINUX DO](https://linux.do/) community for discussion, sharing, and feedback.
300
+ * [Linux DO](https://linux.do)
301
301
 
302
302
  ## License
303
303
 
package/README.md CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  [![Pi](https://img.shields.io/badge/Pi-%3E%3D0.84.2-6f42c1)](https://github.com/earendil-works/pi)
6
6
  [![License](https://img.shields.io/badge/license-AGPL--3.0-blue.svg)](./LICENSE)
7
- [![Version](https://img.shields.io/badge/version-0.3.1-2f81f7.svg)](https://github.com/Qihuanxishini/pi-model-manager)
7
+ [![Version](https://img.shields.io/badge/version-0.3.2-2f81f7.svg)](https://github.com/Qihuanxishini/pi-model-manager)
8
8
 
9
9
  一个面向 [Pi](https://github.com/earendil-works/pi) 的 TUI 模型与接入管理扩展。它以 Pi 原生 `models.json` 为模型配置的唯一权威来源,并提供接入/模型编辑、请求头身份、代理路由和协议兼容配置。
10
10
 
11
- > 当前稳定版为 `0.3.1`,要求 Pi `>=0.84.2`。
11
+ > 当前稳定版为 `0.3.2`,要求 Pi `>=0.84.2`。
12
12
 
13
13
  ## 界面预览
14
14
 
@@ -30,7 +30,7 @@ OpenAI (openai)
30
30
  endpoint https://api.openai.com/v1
31
31
  proxy direct
32
32
  api Responses · headers Auto→Codex · auth env
33
- models gpt-5.1, gpt-5.1-mini
33
+ models gpt-5.6-sol, gpt-5.6-terra
34
34
 
35
35
  ↑↓ 选择 Enter 进入 N 新建接入 D 删除接入 H 请求头 Esc 退出 / 搜索
36
36
  ────────────────────────────────────────────────────────────────────────────────────────
@@ -48,8 +48,8 @@ Responses · 2 模型 · headers Auto→Codex · proxy direct · auth env
48
48
  endpoint https://api.openai.com/v1
49
49
 
50
50
  模型 ID 显示名 输入 Thinking 上下文
51
- ❯ gpt-5.1 默认 文本,视觉 开 400K
52
- gpt-5.1-mini 默认 文本,视觉 开 400K
51
+ ❯ gpt-5.6-sol 默认 文本,视觉 开 1.1M
52
+ gpt-5.6-terra 默认 文本,视觉 开 1.1M
53
53
 
54
54
  ↑↓ 选择 Enter 编辑模型 A 添加模型 E 编辑接入 D 删除模型 Esc 返回 / 搜索
55
55
  ────────────────────────────────────────────────────────────────────────────────────────
@@ -82,17 +82,17 @@ Ctrl+S 保存并同步 models.json;不切换当前会话模型
82
82
 
83
83
  ```text
84
84
  ────────────────────────────────────────────────────────────────────────────────────────
85
- 编辑模型 gpt-5.1
85
+ 编辑模型 gpt-5.6-sol
86
86
  接入 openai · API Responses
87
87
  Ctrl+S 保存并启用模型;不切换当前会话模型
88
88
 
89
- 模型 ID gpt-5.1
89
+ 模型 ID gpt-5.6-sol
90
90
  重新拉取 上游模型列表
91
91
  显示名称 默认 = 模型 ID
92
92
  ❯ 视觉支持 开启
93
93
  Thinking 开启
94
94
  Fast mode 关闭
95
- 上下文窗口 400000
95
+ 上下文窗口 1050000
96
96
  最大输出 128000
97
97
  请求头 跟随接入(Auto→Codex)
98
98
 
@@ -108,14 +108,14 @@ Ctrl+S 保存并启用模型;不切换当前会话模型
108
108
  搜索: <直接输入搜索>
109
109
  匹配 9 / 9 · 页码 1 / 2
110
110
 
111
- dall-e-3
112
- gpt-4.1
113
- gpt-4.1-mini
114
- ❯ gpt-5.1 ← 当前
115
- gpt-5.1-codex
116
- gpt-5.1-mini
117
- o4-mini
118
- text-embedding-3-large
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
119
 
120
120
  ↑↓ 选择 · ←→/PgUp/PgDn 翻页 · 输入搜索 · Backspace 删除 · Enter 确认 · Esc 取消
121
121
  ────────────────────────────────────────────────────────────────────────────────────────
@@ -231,8 +231,8 @@ Base URL 在填入时就会归一化为各协议 SDK 可直接使用的根地址
231
231
 
232
232
  当前内置值来自真实客户端请求并已移除认证信息:
233
233
 
234
- - Claude Code `2.1.232`
235
- - Codex TUI `0.147.0`
234
+ - Claude Code `2.1.243`
235
+ - Codex TUI `0.149.1`
236
236
 
237
237
  这些值只用于兼容需要识别客户端身份的 API 中转,不代替 API key。公开仓库和 npm 包**不包含请求捕获工具、用户抓包、认证头或本机状态**。如果内置值不适合你的服务,请关闭身份头或创建自定义请求头。
238
238
 
@@ -299,9 +299,9 @@ npm pack --dry-run
299
299
 
300
300
  请通过 [GitHub Issues](https://github.com/Qihuanxishini/pi-model-manager/issues) 提交可复现的问题。报告配置问题时,请删除 API key、认证头、代理凭据和私有 endpoint。
301
301
 
302
- ## 致谢
302
+ ## 友情链接
303
303
 
304
- 感谢 [LINUX DO](https://linux.do/) 社区的讨论、分享和反馈。
304
+ * [Linux DO](https://linux.do)
305
305
 
306
306
  ## 许可证
307
307
 
package/i18n.ts CHANGED
@@ -75,6 +75,17 @@ const ENGLISH_MESSAGES = {
75
75
  "本机代理": "Local proxy",
76
76
  "代理地址": "Proxy URL",
77
77
  "认证头": "Auth header",
78
+ "协议兼容": "Protocol compatibility",
79
+ "自动 · Pi 默认": "Auto · Pi default",
80
+ "标准 · developer": "Standard · developer",
81
+ "兼容 · system": "Compatible · system",
82
+ "选择协议兼容": "Select protocol compatibility",
83
+ "自动 — 不写强制配置,保持 Pi 当前判断": "Auto — keep Pi's current detection without an override",
84
+ "标准 — 对 reasoning 模型使用 developer role,适合标准 OpenAI 端点": "Standard — use the developer role for reasoning models on conformant OpenAI endpoints",
85
+ "兼容 — 强制 system role,适合忽略 developer 的中转": "Compatible — force the system role for relays that ignore developer",
86
+ "自动模式:由 Pi 判断系统提示词使用 developer 或 system role。": "Auto mode: Pi decides whether the system prompt uses the developer or system role.",
87
+ "标准模式:reasoning 模型的系统提示词使用 developer role。": "Standard mode: reasoning-model system prompts use the developer role.",
88
+ "兼容模式:系统提示词强制使用 system role,适合忽略 developer 的中转。": "Compatibility mode: the system prompt always uses the system role for relays that ignore developer.",
78
89
  "接入 ID 必填,且不能与已有或 pi 内置接入重复": "Provider ID is required and must not duplicate an existing or built-in Pi provider",
79
90
  "Ctrl+S 保存并同步 models.json;不切换当前会话模型": "Ctrl+S saves and syncs models.json without switching the current session model",
80
91
  "选择 API 协议": "Select API protocol",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-model-manager",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "A TUI model and provider manager for Pi with native models.json persistence, request-header profiles, proxy routing, and protocol compatibility.",
5
5
  "type": "module",
6
6
  "main": "./index.ts",
@@ -1,10 +1,10 @@
1
1
  // 由私有 request-capture-service 根据真实客户端请求生成;公开插件仅消费这些脱敏后的内置值。
2
2
 
3
3
  export const CLAUDE_CODE_CLIENT_HEADERS: Record<string, string> = {
4
- "anthropic-beta": "claude-code-20250219,context-1m-2025-08-07,interleaved-thinking-2025-05-14,thinking-token-count-2026-05-13,context-management-2025-06-27,prompt-caching-scope-2026-01-05,mid-conversation-system-2026-04-07,effort-2025-11-24",
4
+ "anthropic-beta": "claude-code-20250219,context-1m-2025-08-07,interleaved-thinking-2025-05-14,thinking-token-count-2026-05-13,context-management-2025-06-27,prompt-caching-scope-2026-01-05,mid-conversation-system-2026-04-07,effort-2025-11-24,fallback-credit-2026-06-01",
5
5
  "anthropic-dangerous-direct-browser-access": "true",
6
6
  "anthropic-version": "2023-06-01",
7
- "user-agent": "claude-cli/2.1.232 (external, sdk-cli)",
7
+ "user-agent": "claude-cli/2.1.243 (external, sdk-cli)",
8
8
  "x-app": "cli",
9
9
  "x-stainless-arch": "x64",
10
10
  "x-stainless-lang": "js",
@@ -18,6 +18,6 @@ export const CLAUDE_CODE_CLIENT_HEADERS: Record<string, string> = {
18
18
 
19
19
  export const CODEX_CLI_CLIENT_HEADERS: Record<string, string> = {
20
20
  "originator": "codex-tui",
21
- "user-agent": "codex-tui/0.147.0 (Windows 10.0.26200; x86_64) unknown (codex-tui; 0.147.0)",
21
+ "user-agent": "codex-tui/0.149.1 (Windows 10.0.26200; x86_64) unknown (codex-tui; 0.149.1)",
22
22
  "x-codex-beta-features": "remote_compaction_v2",
23
23
  };
@@ -99,6 +99,10 @@ export function switchProviderDraftApiPreset(draft: ProviderDraft, nextApi: ApiK
99
99
  const replaceBaseUrl = stillUsesPresetUrl(draft.baseUrl, previousPreset.baseUrl);
100
100
  const replaceApiKey = draft.apiKey === previousPreset.apiKey;
101
101
  draft.api = nextApi;
102
+ // [喵喵喵]: 协议切换回来时保留用户原先的选择;首次切入 Chat 才补默认自动模式。
103
+ if (nextApi === "openai-completions" && draft.openAIChatDeveloperRole === undefined) {
104
+ draft.openAIChatDeveloperRole = "auto";
105
+ }
102
106
  // [喵喵喵]: 版本路径规则随协议而变(OpenAI 要 /v1、Anthropic 不要),
103
107
  // 保留的自定义地址必须按新协议重新归一化,否则切完协议就指向错误端点。
104
108
  draft.baseUrl = replaceBaseUrl ? nextPreset.baseUrl : resolveRuntimeBaseUrl(nextApi, draft.baseUrl);
package/state-document.ts CHANGED
@@ -23,6 +23,7 @@ import { resolveRuntimeBaseUrl } from "./runtime-base-url.ts";
23
23
  import type {
24
24
  ApiKind,
25
25
  CompatSettings,
26
+ OpenAIChatDeveloperRole,
26
27
  ModelDraft,
27
28
  ProviderDraft,
28
29
  RequestHeaderProfileDraft,
@@ -44,6 +45,12 @@ function isApiKind(value: unknown): value is ApiKind {
44
45
  return typeof value === "string" && API_KINDS.includes(value as ApiKind);
45
46
  }
46
47
 
48
+ function getOpenAIChatDeveloperRole(compat: CompatSettings | undefined): OpenAIChatDeveloperRole {
49
+ if (compat?.supportsDeveloperRole === true) return "developer";
50
+ if (compat?.supportsDeveloperRole === false) return "system";
51
+ return "auto";
52
+ }
53
+
47
54
  export function getModelFullId(providerId: string, modelId: string): string {
48
55
  return `${providerId}/${modelId}`;
49
56
  }
@@ -77,6 +84,7 @@ export function createProviderDraft(api: ApiKind = "openai-responses"): Provider
77
84
  providerId: "",
78
85
  providerName: preset.defaultProviderName,
79
86
  api,
87
+ openAIChatDeveloperRole: "auto",
80
88
  baseUrl: preset.baseUrl,
81
89
  apiKey: preset.apiKey,
82
90
  authHeader: preset.authHeader,
@@ -95,6 +103,7 @@ export function createProviderDraftFromStored(providerId: string, stored: Stored
95
103
  providerId,
96
104
  providerName: stored.name ?? (providerId.replace(/^custom-/, "") || preset.defaultProviderName),
97
105
  api,
106
+ openAIChatDeveloperRole: getOpenAIChatDeveloperRole(stored.compat),
98
107
  baseUrl: stored.baseUrl ?? preset.baseUrl,
99
108
  apiKey: stored.apiKey ?? "",
100
109
  authHeader: stored.authHeader ?? preset.authHeader,
@@ -277,6 +286,10 @@ export function getProviderChangeWarnings(
277
286
  if ((current.apiKey ?? "") !== draft.apiKey.trim()) changes.push("API key");
278
287
  if ((current.api ?? "") !== draft.api) changes.push(t("API 协议"));
279
288
  if ((current.authHeader ?? false) !== draft.authHeader) changes.push(t("认证头"));
289
+ if (draft.api === "openai-completions"
290
+ && getOpenAIChatDeveloperRole(current.compat) !== (draft.openAIChatDeveloperRole ?? "auto")) {
291
+ changes.push(t("协议兼容"));
292
+ }
280
293
  if ((current.clientHeaderProfile ?? "recommended") !== draft.clientHeaderProfile
281
294
  || (current.requestHeaderProfileId ?? "") !== (draft.requestHeaderProfileId ?? ""))
282
295
  changes.push(t("请求头"));
@@ -352,6 +365,13 @@ function buildProviderFromDraft(
352
365
  } else {
353
366
  delete next.customClientHeaders;
354
367
  }
368
+ if (draft.api === "openai-completions" && draft.openAIChatDeveloperRole !== undefined) {
369
+ const compat: CompatSettings = cloneJson(next.compat) ?? {};
370
+ if (draft.openAIChatDeveloperRole === "auto") delete compat.supportsDeveloperRole;
371
+ else compat.supportsDeveloperRole = draft.openAIChatDeveloperRole === "developer";
372
+ if (Object.keys(compat).length > 0) next.compat = compat;
373
+ else delete next.compat;
374
+ }
355
375
  return next;
356
376
  }
357
377
 
@@ -9,8 +9,8 @@ import { t } from "../i18n.ts";
9
9
  import { switchProviderDraftApiPreset } from "../presets/providers.ts";
10
10
  import { redactUrlForDisplay } from "../sensitive-redaction.ts";
11
11
  import { resolveRuntimeBaseUrl } from "../runtime-base-url.ts";
12
- import { DEFAULT_PROVIDER_HTTP_PROXY_URL } from "../types.ts";
13
- import { showOptionPicker, showPersistentFormMenu, padLabel, type MenuCursor } from "./persistent-menu.ts";
12
+ import { DEFAULT_PROVIDER_HTTP_PROXY_URL, type OpenAIChatDeveloperRole } from "../types.ts";
13
+ import { showOptionPicker, showPersistentFormMenu, padLabel, type HorizontalDirection, type MenuCursor } from "./persistent-menu.ts";
14
14
  import {
15
15
  describeProfile,
16
16
  formatApiShort,
@@ -28,6 +28,33 @@ interface FieldRow {
28
28
  adjustable?: boolean;
29
29
  }
30
30
 
31
+ const OPENAI_CHAT_DEVELOPER_ROLE_ORDER: readonly OpenAIChatDeveloperRole[] = ["auto", "developer", "system"];
32
+
33
+ function getOpenAIChatDeveloperRole(draft: ProviderDraft): OpenAIChatDeveloperRole {
34
+ return draft.openAIChatDeveloperRole ?? "auto";
35
+ }
36
+
37
+ function describeOpenAIChatDeveloperRole(role: OpenAIChatDeveloperRole): string {
38
+ if (role === "developer") return t("标准 · developer");
39
+ if (role === "system") return t("兼容 · system");
40
+ return t("自动 · Pi 默认");
41
+ }
42
+
43
+ function getOpenAIChatDeveloperRoleHint(role: OpenAIChatDeveloperRole): string {
44
+ if (role === "developer") return t("标准模式:reasoning 模型的系统提示词使用 developer role。");
45
+ if (role === "system") return t("兼容模式:系统提示词强制使用 system role,适合忽略 developer 的中转。");
46
+ return t("自动模式:由 Pi 判断系统提示词使用 developer 或 system role。");
47
+ }
48
+
49
+ function cycleOpenAIChatDeveloperRole(
50
+ role: OpenAIChatDeveloperRole,
51
+ direction: HorizontalDirection,
52
+ ): OpenAIChatDeveloperRole {
53
+ const index = OPENAI_CHAT_DEVELOPER_ROLE_ORDER.indexOf(role);
54
+ const offset = direction === "right" ? 1 : -1;
55
+ return OPENAI_CHAT_DEVELOPER_ROLE_ORDER[(index + offset + OPENAI_CHAT_DEVELOPER_ROLE_ORDER.length) % OPENAI_CHAT_DEVELOPER_ROLE_ORDER.length]!;
56
+ }
57
+
31
58
  function buildRows(
32
59
  draft: ProviderDraft,
33
60
  requestHeaderProfiles: Record<string, StoredRequestHeaderProfile>,
@@ -38,23 +65,38 @@ function buildRows(
38
65
  const profileDisplay = inlineCustomProfile
39
66
  ? t("内联自定义请求头({count}项)", { count: Object.keys(draft.customClientHeaders).length })
40
67
  : describeProfile(draft.clientHeaderProfile, draft.api, draft.requestHeaderProfileId, requestHeaderProfiles);
41
- return [
68
+ const rows: FieldRow[] = [
42
69
  { id: "api", label: t("API 协议"), value: draft.api },
43
70
  { id: "providerId", label: t("接入 ID(必填)"), value: draft.providerId || t("<必填>") },
44
71
  { id: "providerName", label: t("名称"), value: draft.providerName || t("<空>") },
45
72
  { id: "baseUrl", label: "Base URL", value: draft.baseUrl },
73
+ ];
74
+ if (draft.api === "openai-completions") {
75
+ rows.push({
76
+ id: "openAIChatDeveloperRole",
77
+ label: t("协议兼容"),
78
+ value: describeOpenAIChatDeveloperRole(getOpenAIChatDeveloperRole(draft)),
79
+ adjustable: true,
80
+ });
81
+ }
82
+ rows.push(
46
83
  { id: "httpProxyEnabled", label: t("本机代理"), value: draft.httpProxyEnabled ? t("开启") : t("关闭"), adjustable: true },
47
84
  { id: "httpProxyUrl", label: t("代理地址"), value: draft.httpProxyEnabled ? redactUrlForDisplay(draft.httpProxyUrl || DEFAULT_PROVIDER_HTTP_PROXY_URL) : t("关闭时不使用") },
48
85
  { id: "apiKey", label: "API key", value: maskSecret(draft.apiKey) },
49
86
  { id: "authHeader", label: t("认证头"), value: draft.authHeader ? "Bearer" : t("默认") },
50
87
  { id: "clientHeaderProfile", label: t("请求头"), value: profileDisplay },
51
- ];
88
+ );
89
+ return rows;
52
90
  }
53
91
 
54
92
 
55
93
 
56
- // 开关字段在两个方向上都是取反,因此不看 direction;返回是否真的切换了字段。
57
- function applyHorizontalToggle(draft: ProviderDraft, fieldId: string): boolean {
94
+ // 二值开关的两个方向都取反;三态协议兼容按方向循环。
95
+ function applyHorizontalToggle(draft: ProviderDraft, fieldId: string, direction: HorizontalDirection): boolean {
96
+ if (fieldId === "openAIChatDeveloperRole") {
97
+ draft.openAIChatDeveloperRole = cycleOpenAIChatDeveloperRole(getOpenAIChatDeveloperRole(draft), direction);
98
+ return true;
99
+ }
58
100
  if (fieldId !== "httpProxyEnabled") return false;
59
101
  draft.httpProxyEnabled = !draft.httpProxyEnabled;
60
102
  if (draft.httpProxyEnabled && !draft.httpProxyUrl.trim()) draft.httpProxyUrl = DEFAULT_PROVIDER_HTTP_PROXY_URL;
@@ -100,6 +142,20 @@ async function editField(
100
142
  if (choice) switchProviderDraftApiPreset(draft, choice.id);
101
143
  return;
102
144
  }
145
+ if (fieldId === "openAIChatDeveloperRole") {
146
+ const choice = await showOptionPicker(
147
+ ctx,
148
+ t("选择协议兼容"),
149
+ [
150
+ { id: "auto", label: t("自动 — 不写强制配置,保持 Pi 当前判断") },
151
+ { id: "developer", label: t("标准 — 对 reasoning 模型使用 developer role,适合标准 OpenAI 端点") },
152
+ { id: "system", label: t("兼容 — 强制 system role,适合忽略 developer 的中转") },
153
+ ],
154
+ getOpenAIChatDeveloperRole(draft),
155
+ );
156
+ if (choice) draft.openAIChatDeveloperRole = choice.id as OpenAIChatDeveloperRole;
157
+ return;
158
+ }
103
159
  if (fieldId === "authHeader") {
104
160
  const choice = await showOptionPicker(
105
161
  ctx,
@@ -189,6 +245,17 @@ export async function editProvider(
189
245
  }));
190
246
  const rows = buildRows(draft, requestHeaderProfiles);
191
247
  const menuRows = toMenuRows(rows);
248
+ const getSummaryLines = (): string[] => {
249
+ const summaryLines = [
250
+ `API ${formatApiShort(draft.api)} · ${t("请求头")} ${describeProfile(draft.clientHeaderProfile, draft.api, draft.requestHeaderProfileId, requestHeaderProfiles)}`,
251
+ t("接入 ID 必填,且不能与已有或 pi 内置接入重复"),
252
+ t("Ctrl+S 保存并同步 models.json;不切换当前会话模型"),
253
+ ];
254
+ if (draft.api === "openai-completions") {
255
+ summaryLines.push(getOpenAIChatDeveloperRoleHint(getOpenAIChatDeveloperRole(draft)));
256
+ }
257
+ return summaryLines;
258
+ };
192
259
  const action = await showPersistentFormMenu(
193
260
  ctx,
194
261
  titlePrefix,
@@ -196,13 +263,9 @@ export async function editProvider(
196
263
  menuRows,
197
264
  cursor,
198
265
  {
199
- summaryLines: [
200
- `API ${formatApiShort(draft.api)} · ${t("请求头")} ${describeProfile(draft.clientHeaderProfile, draft.api, draft.requestHeaderProfileId, requestHeaderProfiles)}`,
201
- t("接入 ID 必填,且不能与已有或 pi 内置接入重复"),
202
- t("Ctrl+S 保存并同步 models.json;不切换当前会话模型"),
203
- ],
204
- onAdjust: (id) => {
205
- if (!applyHorizontalToggle(draft, id)) return undefined;
266
+ getSummaryLines,
267
+ onAdjust: (id, direction) => {
268
+ if (!applyHorizontalToggle(draft, id, direction)) return undefined;
206
269
  return toMenuRows(buildRows(draft, requestHeaderProfiles));
207
270
  },
208
271
  hints: [
@@ -29,6 +29,8 @@ export interface MenuHint {
29
29
 
30
30
  export interface PersistentMenuOptions {
31
31
  summaryLines?: readonly string[];
32
+ // [喵喵喵]: 就地切换字段时,摘要也可能依赖草稿状态;渲染时取值才能同步刷新。
33
+ getSummaryLines?: () => readonly string[];
32
34
  // [喵喵喵]: 渲染回调拿到 theme 才能给列与详情上语义色;theme 只存在于 custom 回调作用域。
33
35
  tableHeader?: string | ((width: number, theme: Theme) => string);
34
36
  formatRow?: (row: MenuRow, width: number, theme: Theme) => string;
@@ -419,7 +421,10 @@ function createPersistentMenu<TAction extends MenuAction | FormMenuAction | Shor
419
421
 
420
422
  const border = theme.fg("borderMuted", "─".repeat(Math.max(0, width)));
421
423
  const hintLines = layoutHintLines(getHints(), theme, width);
422
- const summaryLines = (options.summaryLines ?? (help ? help.split("\n") : []))
424
+ const summarySource = options.getSummaryLines?.()
425
+ ?? options.summaryLines
426
+ ?? (help ? help.split("\n") : []);
427
+ const summaryLines = summarySource
423
428
  .map((line) => truncateToWidth(theme.fg("dim", line), width));
424
429
  const searchLine = searchable && (searchActive || searchQuery) ? renderQueryLine(width) : undefined;
425
430
  const tableHeaderText = typeof options.tableHeader === "function"
package/types.ts CHANGED
@@ -12,6 +12,7 @@ type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "
12
12
  export type ThinkingLevelMap = Partial<Record<ThinkingLevel, string | null>>;
13
13
  export type ReasoningMode = "enabled" | "disabled";
14
14
  export type AnthropicThinkingProtocol = "adaptive" | "legacy";
15
+ export type OpenAIChatDeveloperRole = "auto" | "developer" | "system";
15
16
  export type BuiltInClientHeaderProfileId = "claude-code" | "codex-cli";
16
17
  export type ClientHeaderProfileId = "recommended" | "disabled" | BuiltInClientHeaderProfileId | "custom";
17
18
  export type CompatSettings = Record<string, unknown>;
@@ -105,6 +106,8 @@ export interface ProviderDraft {
105
106
  providerId: string;
106
107
  providerName: string;
107
108
  api: ApiKind;
109
+ /** Chat Completions 的 system prompt role;auto 不写 compat 覆盖。 */
110
+ openAIChatDeveloperRole?: OpenAIChatDeveloperRole;
108
111
  baseUrl: string;
109
112
  apiKey: string;
110
113
  authHeader: boolean;