pi-model-manager 0.3.3 → 0.3.4

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/i18n.ts CHANGED
@@ -76,15 +76,12 @@ const ENGLISH_MESSAGES = {
76
76
  "代理地址": "Proxy URL",
77
77
  "认证头": "Auth header",
78
78
  "协议兼容": "Protocol compatibility",
79
- "自动 · Pi 默认": "Auto · Pi default",
80
- "标准 · developer": "Standard · developer",
79
+ "标准 · Pi 默认": "Standard · Pi default",
81
80
  "兼容 · system": "Compatible · system",
82
81
  "选择协议兼容": "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",
82
+ "标准 — 保持 Pi 默认兼容判断": "Standard — keep Pi's default compatibility detection",
85
83
  "兼容 — 强制 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.",
84
+ "标准模式:保持 Pi 默认兼容判断。": "Standard mode: keep Pi's default compatibility detection.",
88
85
  "兼容模式:系统提示词强制使用 system role,适合忽略 developer 的中转。": "Compatibility mode: the system prompt always uses the system role for relays that ignore developer.",
89
86
  "接入 ID 必填,且不能与已有或 pi 内置接入重复": "Provider ID is required and must not duplicate an existing or built-in Pi provider",
90
87
  "Ctrl+S 保存并同步 models.json;不切换当前会话模型": "Ctrl+S saves and syncs models.json without switching the current session model",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-model-manager",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
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",
@@ -99,9 +99,9 @@ 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";
102
+ // [喵喵喵]: 协议切换回来时保留用户原先的选择;首次切入 Chat 才补标准模式。
103
+ if (nextApi === "openai-completions" && draft.openAIChatCompatibilityMode === undefined) {
104
+ draft.openAIChatCompatibilityMode = "standard";
105
105
  }
106
106
  // [喵喵喵]: 版本路径规则随协议而变(OpenAI 要 /v1、Anthropic 不要),
107
107
  // 保留的自定义地址必须按新协议重新归一化,否则切完协议就指向错误端点。
package/state-document.ts CHANGED
@@ -23,7 +23,7 @@ import { resolveRuntimeBaseUrl } from "./runtime-base-url.ts";
23
23
  import type {
24
24
  ApiKind,
25
25
  CompatSettings,
26
- OpenAIChatDeveloperRole,
26
+ OpenAIChatCompatibilityMode,
27
27
  ModelDraft,
28
28
  ProviderDraft,
29
29
  RequestHeaderProfileDraft,
@@ -45,10 +45,8 @@ function isApiKind(value: unknown): value is ApiKind {
45
45
  return typeof value === "string" && API_KINDS.includes(value as ApiKind);
46
46
  }
47
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";
48
+ function getOpenAIChatCompatibilityMode(compat: CompatSettings | undefined): OpenAIChatCompatibilityMode {
49
+ return compat?.supportsDeveloperRole === false ? "compatible" : "standard";
52
50
  }
53
51
 
54
52
  export function getModelFullId(providerId: string, modelId: string): string {
@@ -84,7 +82,7 @@ export function createProviderDraft(api: ApiKind = "openai-responses"): Provider
84
82
  providerId: "",
85
83
  providerName: preset.defaultProviderName,
86
84
  api,
87
- openAIChatDeveloperRole: "auto",
85
+ openAIChatCompatibilityMode: "standard",
88
86
  baseUrl: preset.baseUrl,
89
87
  apiKey: preset.apiKey,
90
88
  authHeader: preset.authHeader,
@@ -103,7 +101,7 @@ export function createProviderDraftFromStored(providerId: string, stored: Stored
103
101
  providerId,
104
102
  providerName: stored.name ?? (providerId.replace(/^custom-/, "") || preset.defaultProviderName),
105
103
  api,
106
- openAIChatDeveloperRole: getOpenAIChatDeveloperRole(stored.compat),
104
+ openAIChatCompatibilityMode: getOpenAIChatCompatibilityMode(stored.compat),
107
105
  baseUrl: stored.baseUrl ?? preset.baseUrl,
108
106
  apiKey: stored.apiKey ?? "",
109
107
  authHeader: stored.authHeader ?? preset.authHeader,
@@ -287,7 +285,7 @@ export function getProviderChangeWarnings(
287
285
  if ((current.api ?? "") !== draft.api) changes.push(t("API 协议"));
288
286
  if ((current.authHeader ?? false) !== draft.authHeader) changes.push(t("认证头"));
289
287
  if (draft.api === "openai-completions"
290
- && getOpenAIChatDeveloperRole(current.compat) !== (draft.openAIChatDeveloperRole ?? "auto")) {
288
+ && getOpenAIChatCompatibilityMode(current.compat) !== (draft.openAIChatCompatibilityMode ?? "standard")) {
291
289
  changes.push(t("协议兼容"));
292
290
  }
293
291
  if ((current.clientHeaderProfile ?? "recommended") !== draft.clientHeaderProfile
@@ -365,10 +363,10 @@ function buildProviderFromDraft(
365
363
  } else {
366
364
  delete next.customClientHeaders;
367
365
  }
368
- if (draft.api === "openai-completions" && draft.openAIChatDeveloperRole !== undefined) {
366
+ if (draft.api === "openai-completions" && draft.openAIChatCompatibilityMode !== undefined) {
369
367
  const compat: CompatSettings = cloneJson(next.compat) ?? {};
370
- if (draft.openAIChatDeveloperRole === "auto") delete compat.supportsDeveloperRole;
371
- else compat.supportsDeveloperRole = draft.openAIChatDeveloperRole === "developer";
368
+ if (draft.openAIChatCompatibilityMode === "standard") delete compat.supportsDeveloperRole;
369
+ else compat.supportsDeveloperRole = false;
372
370
  if (Object.keys(compat).length > 0) next.compat = compat;
373
371
  else delete next.compat;
374
372
  }
@@ -9,7 +9,7 @@ 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, type OpenAIChatDeveloperRole } from "../types.ts";
12
+ import { DEFAULT_PROVIDER_HTTP_PROXY_URL, type OpenAIChatCompatibilityMode } from "../types.ts";
13
13
  import { showOptionPicker, showPersistentFormMenu, padLabel, type HorizontalDirection, type MenuCursor } from "./persistent-menu.ts";
14
14
  import {
15
15
  describeProfile,
@@ -28,31 +28,29 @@ interface FieldRow {
28
28
  adjustable?: boolean;
29
29
  }
30
30
 
31
- const OPENAI_CHAT_DEVELOPER_ROLE_ORDER: readonly OpenAIChatDeveloperRole[] = ["auto", "developer", "system"];
31
+ const OPENAI_CHAT_COMPATIBILITY_MODE_ORDER: readonly OpenAIChatCompatibilityMode[] = ["standard", "compatible"];
32
32
 
33
- function getOpenAIChatDeveloperRole(draft: ProviderDraft): OpenAIChatDeveloperRole {
34
- return draft.openAIChatDeveloperRole ?? "auto";
33
+ function getOpenAIChatCompatibilityMode(draft: ProviderDraft): OpenAIChatCompatibilityMode {
34
+ return draft.openAIChatCompatibilityMode ?? "standard";
35
35
  }
36
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 默认");
37
+ function describeOpenAIChatCompatibilityMode(mode: OpenAIChatCompatibilityMode): string {
38
+ if (mode === "compatible") return t("兼容 · system");
39
+ return t("标准 · Pi 默认");
41
40
  }
42
41
 
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。");
42
+ function getOpenAIChatCompatibilityModeHint(mode: OpenAIChatCompatibilityMode): string {
43
+ if (mode === "compatible") return t("兼容模式:系统提示词强制使用 system role,适合忽略 developer 的中转。");
44
+ return t("标准模式:保持 Pi 默认兼容判断。");
47
45
  }
48
46
 
49
- function cycleOpenAIChatDeveloperRole(
50
- role: OpenAIChatDeveloperRole,
47
+ function cycleOpenAIChatCompatibilityMode(
48
+ mode: OpenAIChatCompatibilityMode,
51
49
  direction: HorizontalDirection,
52
- ): OpenAIChatDeveloperRole {
53
- const index = OPENAI_CHAT_DEVELOPER_ROLE_ORDER.indexOf(role);
50
+ ): OpenAIChatCompatibilityMode {
51
+ const index = OPENAI_CHAT_COMPATIBILITY_MODE_ORDER.indexOf(mode);
54
52
  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]!;
53
+ return OPENAI_CHAT_COMPATIBILITY_MODE_ORDER[(index + offset + OPENAI_CHAT_COMPATIBILITY_MODE_ORDER.length) % OPENAI_CHAT_COMPATIBILITY_MODE_ORDER.length]!;
56
54
  }
57
55
 
58
56
  function buildRows(
@@ -73,9 +71,9 @@ function buildRows(
73
71
  ];
74
72
  if (draft.api === "openai-completions") {
75
73
  rows.push({
76
- id: "openAIChatDeveloperRole",
74
+ id: "openAIChatCompatibilityMode",
77
75
  label: t("协议兼容"),
78
- value: describeOpenAIChatDeveloperRole(getOpenAIChatDeveloperRole(draft)),
76
+ value: describeOpenAIChatCompatibilityMode(getOpenAIChatCompatibilityMode(draft)),
79
77
  adjustable: true,
80
78
  });
81
79
  }
@@ -91,10 +89,10 @@ function buildRows(
91
89
 
92
90
 
93
91
 
94
- // 二值开关的两个方向都取反;三态协议兼容按方向循环。
92
+ // 二值开关的两个方向都取反。
95
93
  function applyHorizontalToggle(draft: ProviderDraft, fieldId: string, direction: HorizontalDirection): boolean {
96
- if (fieldId === "openAIChatDeveloperRole") {
97
- draft.openAIChatDeveloperRole = cycleOpenAIChatDeveloperRole(getOpenAIChatDeveloperRole(draft), direction);
94
+ if (fieldId === "openAIChatCompatibilityMode") {
95
+ draft.openAIChatCompatibilityMode = cycleOpenAIChatCompatibilityMode(getOpenAIChatCompatibilityMode(draft), direction);
98
96
  return true;
99
97
  }
100
98
  if (fieldId !== "httpProxyEnabled") return false;
@@ -142,18 +140,17 @@ async function editField(
142
140
  if (choice) switchProviderDraftApiPreset(draft, choice.id);
143
141
  return;
144
142
  }
145
- if (fieldId === "openAIChatDeveloperRole") {
143
+ if (fieldId === "openAIChatCompatibilityMode") {
146
144
  const choice = await showOptionPicker(
147
145
  ctx,
148
146
  t("选择协议兼容"),
149
147
  [
150
- { id: "auto", label: t("自动 — 不写强制配置,保持 Pi 当前判断") },
151
- { id: "developer", label: t("标准 — 对 reasoning 模型使用 developer role,适合标准 OpenAI 端点") },
152
- { id: "system", label: t("兼容 — 强制 system role,适合忽略 developer 的中转") },
148
+ { id: "standard", label: t("标准 — 保持 Pi 默认兼容判断") },
149
+ { id: "compatible", label: t("兼容 — 强制 system role,适合忽略 developer 的中转") },
153
150
  ],
154
- getOpenAIChatDeveloperRole(draft),
151
+ getOpenAIChatCompatibilityMode(draft),
155
152
  );
156
- if (choice) draft.openAIChatDeveloperRole = choice.id as OpenAIChatDeveloperRole;
153
+ if (choice) draft.openAIChatCompatibilityMode = choice.id as OpenAIChatCompatibilityMode;
157
154
  return;
158
155
  }
159
156
  if (fieldId === "authHeader") {
@@ -252,7 +249,7 @@ export async function editProvider(
252
249
  t("Ctrl+S 保存并同步 models.json;不切换当前会话模型"),
253
250
  ];
254
251
  if (draft.api === "openai-completions") {
255
- summaryLines.push(getOpenAIChatDeveloperRoleHint(getOpenAIChatDeveloperRole(draft)));
252
+ summaryLines.push(getOpenAIChatCompatibilityModeHint(getOpenAIChatCompatibilityMode(draft)));
256
253
  }
257
254
  return summaryLines;
258
255
  };
package/types.ts CHANGED
@@ -12,7 +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
+ export type OpenAIChatCompatibilityMode = "standard" | "compatible";
16
16
  export type BuiltInClientHeaderProfileId = "claude-code" | "codex-cli";
17
17
  export type ClientHeaderProfileId = "recommended" | "disabled" | BuiltInClientHeaderProfileId | "custom";
18
18
  export type CompatSettings = Record<string, unknown>;
@@ -106,8 +106,8 @@ export interface ProviderDraft {
106
106
  providerId: string;
107
107
  providerName: string;
108
108
  api: ApiKind;
109
- /** Chat Completions 的 system prompt role;auto 不写 compat 覆盖。 */
110
- openAIChatDeveloperRole?: OpenAIChatDeveloperRole;
109
+ /** Chat Completions 系统提示词兼容模式;standard 保持 Pi 默认判断。 */
110
+ openAIChatCompatibilityMode?: OpenAIChatCompatibilityMode;
111
111
  baseUrl: string;
112
112
  apiKey: string;
113
113
  authHeader: boolean;