@mangoc/dsh-sub2api-sync 0.2.5 → 0.2.7
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.md +2 -1
- package/README.zh.md +3 -2
- package/lib/client.cjs +8 -3
- package/lib/client.js +8 -3
- package/lib/index.js +43 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -122,7 +122,8 @@ Routes take effect on the next request. The route suffix is a SHA-256 truncation
|
|
|
122
122
|
## Model Experience
|
|
123
123
|
|
|
124
124
|
- **Context blocks (short form)**: one provider per sub2api group, one relay key per provider, model catalog discovered from the instance; per-model `compat` inherits the user template. Reasoning efforts (`reasoningEfforts`) follow an explicit template when set (including `false`), and otherwise auto-fill per model from the models.dev enrichment.
|
|
125
|
-
- **Reasoning-effort auto-fill**: the models.dev `reasoning_options` effort enumeration maps onto pi-ai's `reasoningEfforts` (`none` → `off: null`, same-name passthrough otherwise). Merging is first-party first: a vendor-official entry (openai/anthropic/google/zhipuai/zai/deepseek/moonshotai/xai/alibaba, vendor-governed cloud hosting) wins outright — including when it carries no effort data (budget-only
|
|
125
|
+
- **Reasoning-effort auto-fill**: the models.dev `reasoning_options` effort enumeration maps onto pi-ai's `reasoningEfforts` (`none` → `off: null`, same-name passthrough otherwise). Merging is first-party first: a vendor-official entry (openai/anthropic/google/zhipuai/zai/deepseek/moonshotai/xai/alibaba, vendor-governed cloud hosting) wins outright — including when it carries no effort data (budget-only older Claude/Gemini entries), which silences aggregator-invented vocabularies; with no first-party entry, aggregator sources intersect. Toggle/budget-only reasoning (older Claude, Gemini, deepseek-v3.2, kimi-k2.x) has no effort-string wire shape and stays template/`compat`-owned.
|
|
126
|
+
- **Native Claude reasoning efforts**: for confirmed adaptive-thinking Claude models with catalog effort metadata (such as Opus 4.6/4.7/4.8 and Sonnet 4.6), syncing over `anthropic-messages` also writes per-model `compat.forceAdaptiveThinking: true`. This SDK switch sends Claude's native `thinking: { type: "adaptive" }` and `output_config: { effort: "max" }` when Max is selected: no OpenAI protocol bridge and no Max-to-token-budget downgrade. Explicit template compat values (including `false`) win; disabled reasoning, legacy/unknown models, missing catalog effort metadata, and other protocols do not auto-enable it. Update the plugin and sync again to repair existing managed routes; subsequent syncs remain idempotent. The usage log records the declared effort, not a measurement of actual thinking.
|
|
126
127
|
- **Display-name enrichment**: the models.dev `name` lands on each pi-ai model entry's `name` field — the display name the model selector and the model-catalog editor (显示名称 column) show. The models.dev " (latest)" family marker is stripped, a name repeating the id is dropped, merging is first-party first (official name overrides, aggregator names fill absences), and a name can be an id's only enriched fact.
|
|
127
128
|
- Model ids come verbatim from the instance; the provider display name is the `providerNameTemplate` rendering of the key name (fallback `Group <id>`).
|
|
128
129
|
|
package/README.zh.md
CHANGED
|
@@ -92,7 +92,8 @@ dsh plugin --profile web add ./packages/llm/sub2api-sync
|
|
|
92
92
|
|
|
93
93
|
- 每分组一个 provider、一把 relay key;模型目录来自实例发现;逐模型 `compat` 继承用户模板;推理档位 `reasoningEfforts` 模板显式设置优先,未设置时按模型自动填充(见下);
|
|
94
94
|
- **模型元数据补全(C4)**:同步时按模型 id 从 models.dev 目录补全**显示名称**(`name`,即模型目录编辑器「显示名称」列)/`contextWindow`/`maxTokens`/图片输入/推理档位——`enrichModelMeta` 开启(缺省)时联网拉取(24h 进程内缓存),失败自动降级到**随包内置快照**(`data/models-dev.snapshot.json`,`pnpm --filter @mangoc/dsh-sub2api-sync models:refresh` 重新生成);关闭则只用内置快照(离线确定);两者都未命中的模型保持路由级缺省 128000/8192/纯文本;
|
|
95
|
-
- **推理档位自动填充**:取 models.dev 条目的 `reasoning_options` 中 `effort` 枚举,映射为 pi-ai 的 `reasoningEfforts`(`none` → `off: null`,其余同名直传)。合并按 **first-party 优先**:官方厂商条目(openai/anthropic/google/zhipuai/zai/deepseek/moonshotai/xai/alibaba 等及官方云托管)存在即胜出——官方条目无 effort
|
|
95
|
+
- **推理档位自动填充**:取 models.dev 条目的 `reasoning_options` 中 `effort` 枚举,映射为 pi-ai 的 `reasoningEfforts`(`none` → `off: null`,其余同名直传)。合并按 **first-party 优先**:官方厂商条目(openai/anthropic/google/zhipuai/zai/deepseek/moonshotai/xai/alibaba 等及官方云托管)存在即胜出——官方条目无 effort 数据(如旧版 Claude/Gemini 的 budget-only 条目)同样压制聚合商的虚报词表;无官方条目时聚合商来源取**交集**。优先级:**模板显式设置(含 `false`)> 每模型自动填充 > 不写字段**;显示名 = `providerNameTemplate` 渲染的 key 名。
|
|
96
|
+
- **Claude 原生推理档位**:对已确认支持 adaptive thinking、且目录有 effort 元数据的 Claude 模型(如 Opus 4.6/4.7/4.8、Sonnet 4.6),仅在 `anthropic-messages` 协议下逐模型自动补齐 `compat.forceAdaptiveThinking: true`。该开关让 SDK 直接发送 Claude 原生的 `thinking: { type: "adaptive" }` 与 `output_config: { effort: "max" }`(以选择 Max 为例),不经过 OpenAI 协议转换,也不将 Max 降成 token budget。用户模板中同名 compat 字段(包括显式 `false`)优先;关闭 reasoning、旧模型、未知别名/新版本、缺少目录 effort 元数据或其他协议都不会自动开启。更新插件并重新同步即可修复已有受管路由,重复同步不重复写入;无需修改 sub2api 的记录值。注意:用量日志的 effort 是请求声明档位,不是实际思考量的测量值。
|
|
96
97
|
- **显示名称富化**:取 models.dev 条目的 `name` 写入 pi-ai 模型条目的 `name` 字段(模型选择器与「已自定义模型目录」编辑器的显示名);剥离 models.dev 的 " (latest)" 家族标记,名称与模型 id 相同(无信息量)时不写;合并同样 first-party 优先(官方名称覆盖,聚合商名称仅补缺),纯名称条目也参与富化。
|
|
97
98
|
|
|
98
99
|
## Known Limitations and Deferred Work
|
|
@@ -104,7 +105,7 @@ dsh plugin --profile web add ./packages/llm/sub2api-sync
|
|
|
104
105
|
- **客户端半部只允许基线外部模块**(React / Cordis / ui-primitives / ui-slots / client-store / ui-dockkit)——客户端代码不得值导入 `config.ts`(会把 schemastery 拽进浏览器 bundle,动态模块表无此行,加载即静默失败);`test/client-bundle.test.ts` 是产物守卫。
|
|
105
106
|
- 实例前置 Cloudflare 时,需在 zone 放行 `/api/v1/*` 的宿主侧调用(WAF skip 规则)。
|
|
106
107
|
- 元数据补全会向 models.dev 发起一次公开目录请求(不带任何凭据与对话内容);`enrichModelMeta: false` 可完全离线(仅内置快照)。
|
|
107
|
-
- 推理档位自动填充只覆盖 models.dev 提供 `effort` 枚举的模型(OpenAI gpt-5 系/o3、GLM 5.x、Qwen3.8、DeepSeek V4 系等);`toggle`/`budget_tokens`
|
|
108
|
+
- 推理档位自动填充只覆盖 models.dev 提供 `effort` 枚举的模型(OpenAI gpt-5 系/o3、GLM 5.x、Qwen3.8、DeepSeek V4 系等);`toggle`/`budget_tokens` 型推理(旧版 Claude、Gemini、deepseek-v3.2、kimi-k2.x 等)的线上形态不是 effort 字符串,`reasoningEfforts` 无法表达,仍由模板/`compat` 管辖。
|
|
108
109
|
- 用量查询(`GET /v1/usage`)是已决策的非目标。
|
|
109
110
|
- 与社区插件 `GodD6366/dsh-sub2api` 同装:路由名不冲突(本插件 `sub2api-<10-hex>` 摘要形态),各自管理条目与凭据引用。
|
|
110
111
|
|
package/lib/client.cjs
CHANGED
|
@@ -793,8 +793,13 @@ const CSS = `
|
|
|
793
793
|
|
|
794
794
|
/* The options panel: fixed-positioned from the trigger (escapes the modal
|
|
795
795
|
card's overflow clip), width-matched to it, search pinned on top, options
|
|
796
|
-
scrolling below.
|
|
796
|
+
scrolling below. position: fixed is load-bearing: MenuSurface defaults to
|
|
797
|
+
position: relative, and without this rule the panel becomes a flex item
|
|
798
|
+
inside the form row while the viewport-coordinate top/left from
|
|
799
|
+
useAnchoredPosition act as relative offsets — the panel displaces across
|
|
800
|
+
the dialog and stays clipped by the card (the blank floating box bug). */
|
|
797
801
|
.s2s-groupPanel {
|
|
802
|
+
position: fixed;
|
|
798
803
|
display: flex;
|
|
799
804
|
flex-direction: column;
|
|
800
805
|
box-sizing: border-box;
|
|
@@ -1396,8 +1401,8 @@ function GroupPicker({ groups, value, placeholder, searchPlaceholder, emptyLabel
|
|
|
1396
1401
|
ref: panelRef,
|
|
1397
1402
|
className: "s2s-groupPanel",
|
|
1398
1403
|
role: "listbox",
|
|
1399
|
-
style:
|
|
1400
|
-
...position,
|
|
1404
|
+
style: {
|
|
1405
|
+
...position === null ? { visibility: "hidden" } : position,
|
|
1401
1406
|
...triggerWidth > 0 ? { width: `${triggerWidth}px` } : {},
|
|
1402
1407
|
maxHeight: `${maxHeight}px`
|
|
1403
1408
|
},
|
package/lib/client.js
CHANGED
|
@@ -799,8 +799,13 @@ const CSS = `
|
|
|
799
799
|
|
|
800
800
|
/* The options panel: fixed-positioned from the trigger (escapes the modal
|
|
801
801
|
card's overflow clip), width-matched to it, search pinned on top, options
|
|
802
|
-
scrolling below.
|
|
802
|
+
scrolling below. position: fixed is load-bearing: MenuSurface defaults to
|
|
803
|
+
position: relative, and without this rule the panel becomes a flex item
|
|
804
|
+
inside the form row while the viewport-coordinate top/left from
|
|
805
|
+
useAnchoredPosition act as relative offsets — the panel displaces across
|
|
806
|
+
the dialog and stays clipped by the card (the blank floating box bug). */
|
|
803
807
|
.s2s-groupPanel {
|
|
808
|
+
position: fixed;
|
|
804
809
|
display: flex;
|
|
805
810
|
flex-direction: column;
|
|
806
811
|
box-sizing: border-box;
|
|
@@ -1402,8 +1407,8 @@ function GroupPicker({ groups, value, placeholder, searchPlaceholder, emptyLabel
|
|
|
1402
1407
|
ref: panelRef,
|
|
1403
1408
|
className: "s2s-groupPanel",
|
|
1404
1409
|
role: "listbox",
|
|
1405
|
-
style:
|
|
1406
|
-
...position,
|
|
1410
|
+
style: {
|
|
1411
|
+
...position === null ? { visibility: "hidden" } : position,
|
|
1407
1412
|
...triggerWidth > 0 ? { width: `${triggerWidth}px` } : {},
|
|
1408
1413
|
maxHeight: `${maxHeight}px`
|
|
1409
1414
|
},
|
package/lib/index.js
CHANGED
|
@@ -300,8 +300,38 @@ const THINKING_LEVELS = [
|
|
|
300
300
|
"xhigh",
|
|
301
301
|
"max"
|
|
302
302
|
];
|
|
303
|
+
/**
|
|
304
|
+
* Native adaptive-thinking entries confirmed by pi-ai 1.1.0's Anthropic
|
|
305
|
+
* catalog. Keep this allowlist conservative: an effort enum alone is NOT proof
|
|
306
|
+
* of adaptive support (Opus 4.5 has native effort but still uses budget thinking,
|
|
307
|
+
* and aggregators publish effort enums even for older Claude models).
|
|
308
|
+
* Unknown releases/aliases stay explicit-template owned rather than guessed.
|
|
309
|
+
*/
|
|
310
|
+
const ADAPTIVE_CLAUDE_MODELS = new Set([
|
|
311
|
+
"claude-opus-4-6",
|
|
312
|
+
"claude-opus-4-7",
|
|
313
|
+
"claude-opus-4-8",
|
|
314
|
+
"claude-opus-5",
|
|
315
|
+
"claude-opus-5-5",
|
|
316
|
+
"claude-sonnet-4-6",
|
|
317
|
+
"claude-sonnet-5",
|
|
318
|
+
"claude-sonnet-5-5",
|
|
319
|
+
"claude-haiku-5-5",
|
|
320
|
+
"claude-fable-5",
|
|
321
|
+
"claude-fable-5-1"
|
|
322
|
+
]);
|
|
323
|
+
/** Pair catalog effort metadata with its native Anthropic wire mode. */
|
|
324
|
+
function modelCompat(input, model) {
|
|
325
|
+
const template = input.template?.compat;
|
|
326
|
+
const canonicalId = model.id.toLowerCase().replaceAll(".", "-").replace(/(?:-(?:fast|think|thinking|\d{8})|@(?:default|eu))$/, "");
|
|
327
|
+
const adaptive = input.protocol === "anthropic-messages" && input.template?.reasoningEfforts !== false && model.reasoningEfforts !== undefined && ADAPTIVE_CLAUDE_MODELS.has(canonicalId);
|
|
328
|
+
if (!adaptive && template === undefined) return undefined;
|
|
329
|
+
return {
|
|
330
|
+
...adaptive ? { forceAdaptiveThinking: true } : {},
|
|
331
|
+
...template
|
|
332
|
+
};
|
|
333
|
+
}
|
|
303
334
|
function buildProviderProfile(input) {
|
|
304
|
-
const compat = input.template?.compat;
|
|
305
335
|
const reasoning = input.template?.reasoningEfforts;
|
|
306
336
|
const override = input.retryPolicy ?? {};
|
|
307
337
|
const retryPolicy = {
|
|
@@ -319,15 +349,18 @@ function buildProviderProfile(input) {
|
|
|
319
349
|
apiKeyEnv: input.apiKeyEnv,
|
|
320
350
|
api: input.protocol,
|
|
321
351
|
baseURL: baseURLForProtocol(input.instance, input.protocol),
|
|
322
|
-
models: input.models.map((model) =>
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
352
|
+
models: input.models.map((model) => {
|
|
353
|
+
const compat = modelCompat(input, model);
|
|
354
|
+
return {
|
|
355
|
+
id: model.id,
|
|
356
|
+
...model.name !== undefined ? { name: model.name } : {},
|
|
357
|
+
...model.contextWindow !== undefined ? { contextWindow: model.contextWindow } : {},
|
|
358
|
+
...model.maxTokens !== undefined ? { maxTokens: model.maxTokens } : {},
|
|
359
|
+
...model.imageInput === true ? { input: ["text", "image"] } : {},
|
|
360
|
+
...compat !== undefined ? { compat } : {},
|
|
361
|
+
...reasoning === false ? { reasoningEfforts: false } : reasoning !== undefined ? { reasoningEfforts: { ...reasoning } } : model.reasoningEfforts !== undefined ? { reasoningEfforts: { ...model.reasoningEfforts } } : {}
|
|
362
|
+
};
|
|
363
|
+
}),
|
|
331
364
|
...input.template?.reasoning !== undefined ? { reasoning: input.template.reasoning } : {},
|
|
332
365
|
defaultContextWindow: input.defaultContextWindow ?? 128e3,
|
|
333
366
|
defaultMaxTokens: input.defaultMaxTokens ?? 8192,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mangoc/dsh-sub2api-sync",
|
|
3
3
|
"description": "Sync one sub2api instance's groups, keys, and models into dsh-llm-pi-ai provider routes: panel-driven login (password / OAuth), one relay key one provider.",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.7",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Shuai-S",
|
|
7
7
|
"homepage": "https://github.com/Shuai-S/dsh-sub2api-sync#readme",
|