dsh-neartoken 0.15.2 → 0.15.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.md +2 -2
- package/lib/client.js +95 -95
- package/lib/index.js +4 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -194,9 +194,9 @@ Gemini 系走原生 surface 而不是 openai 兼容层:同模型同提示词
|
|
|
194
194
|
- 四套 wire 的 SSE 解析都有「帧样本 → 期望 chunk 序列」回归测试(`src/host/wire-parse.spec.ts`),帧样本取自生产网关的真实响应。网关在内容帧上发 `"usage": null`,只有末帧带真值:任何一处把 `usage` 当对象直接读都会让整条流中途崩掉(曾导致 claude 模型全不可用)。
|
|
195
195
|
- **每个请求都带会话亲和键**:chat 与 responses 发 `prompt_cache_key`,anthropic 发 `metadata.user_id`,取值都是 DSH 的 `GenerateOptions.sessionId`。站点就是靠这个值挑上游渠道的(New API 的「codex cli trace」规则:`^gpt-.*$` + `/v1/responses`,键取自 body 的 `prompt_cache_key`,取不到就把整条规则跳过),而提示词缓存按**上游账号**存 —— 不带键时每个请求随机换账号,缓存永远不中。实测同一 6k 前缀:不带键连发 4 次 `cached_tokens` 全 0;带键后第 2 次起 5888/6011 ≈ 98%。`/v1/chat/completions` 上目前没有对应规则,chat 线即使带键也只是偶发命中,要彻底解决需要站点加一条匹配该路径的亲和规则;anthropic 线的 `metadata.user_id` 同理(规则只作用于 `/v1/messages`,这一条已经匹配)。
|
|
196
196
|
- **anthropic 线显式打缓存断点**:Anthropic 只在 `cache_control` 断点处写缓存,没有断点就整段 prompt 按新输入计价(亲和键只保证落在同一上游账号,不产生缓存)。每个请求打 4 个断点:`tools` 末项、`system` 末块、最后两条消息各自末块 —— harness 每轮全量重放历史,尾部双断点保证下一轮几乎全命中,每轮只写新增片段。实测(Claude Max 超惠分组,~6.3k token 前缀):无断点连发两次 `cache_read` 全 0;打点后第 2 次起 `in=4, cr=6316`,三轮增长历史 `cr` 累积到 10811、`in` 恒为个位数。断点也覆盖 `tool_result` 结尾的轮次(DSH 会话的常态形态)。
|
|
197
|
-
- 推理等级按各协议自己的词汇发送:**anthropic 发 `thinking.type=adaptive` + `output_config.effort`**(不能再用 `thinking.type=enabled` + `budget_tokens`:Claude 5 代直接 400 `requires adaptive thinking`,而 adaptive 在老代际上同样可用,所以统一用它;`minimal` 收敛成 `low
|
|
197
|
+
- 推理等级按各协议自己的词汇发送:**anthropic 发 `thinking.type=adaptive` + `thinking.display=summarized` + `output_config.effort`**(不能再用 `thinking.type=enabled` + `budget_tokens`:Claude 5 代直接 400 `requires adaptive thinking`,而 adaptive 在老代际上同样可用,所以统一用它;`minimal` 收敛成 `low`;`display` 不是装饰:不带它,Claude 5 代的 thinking 块正文为空、只填 signature,而 harness 没有存 signature 的槽位,界面上就表现为「这个模型从不思考」——Claude Opus 5.5 实测不带 `display` 正文 0 字符、带 `display=summarized` 正文 55~132 字符);genai 发 `thinkingConfig` 且带 `includeThoughts`(不带你拿不到思维链);chat 与 responses 发 `reasoning_effort` / `reasoning.effort`。
|
|
198
198
|
- **Gemini 4 换成 `thinkingLevel`**:这一代不再接受 token 预算(发 budget 会 400 `Use thinking level instead`),按 `gemini-<主版本>` ≥ 4 自动切换字段,等级名用 `low` / `medium` / `high` / `max`。
|
|
199
|
-
- 思考历史**不回传**:harness 的 reasoning 块没有 signature 槽位,anthropic 的 `signature_delta` 与 gemini 的 `thoughtSignature`
|
|
199
|
+
- 思考历史**不回传**:harness 的 reasoning 块没有 signature 槽位,anthropic 的 `signature_delta` 与 gemini 的 `thoughtSignature` 都被丢弃。网关在请求没要 `display=summarized` 时给出的正是这种空正文 thinking 块,插件不为空正文建块,所以多轮不会因此报错;接真正的 Anthropic / Gemini 直连渠道时这一条会变成硬限制。
|
|
200
200
|
- 文本与思维块由**第一个非空 delta** 打开,思维块为空时不产生空块;工具调用块在 `content_block_start` 打开,因为 id 与函数名只在那里出现。
|
|
201
201
|
- anthropic 线不硬编码 `max_tokens`:只在调用方给了上限、或开了 thinking 需要余量时才发。给死值会截断长回答。
|
|
202
202
|
- `-c` 后缀是站点自己的约定(带该后缀的模型工具调用不可靠):站点声明了端点类型时插件按声明提供,声明里没有它就不会出现;没有声明时按名字隐藏它的无后缀孪生之外的变体。
|
package/lib/client.js
CHANGED
|
@@ -401,23 +401,23 @@ window.__ModuleLoader__.load({
|
|
|
401
401
|
document.head.appendChild(tag);
|
|
402
402
|
}
|
|
403
403
|
var group_tags_module_css_default = {
|
|
404
|
-
"ratioCheap": "FotuUq_ratioCheap",
|
|
405
|
-
"toneFuchsia": "FotuUq_toneFuchsia",
|
|
406
|
-
"toneIndigo": "FotuUq_toneIndigo",
|
|
407
|
-
"toneEmerald": "FotuUq_toneEmerald",
|
|
408
404
|
"toneCyan": "FotuUq_toneCyan",
|
|
409
|
-
"ratioPricey": "FotuUq_ratioPricey",
|
|
410
405
|
"tonePink": "FotuUq_tonePink",
|
|
411
|
-
"toneLime": "FotuUq_toneLime",
|
|
412
|
-
"toneRose": "FotuUq_toneRose",
|
|
413
|
-
"tag": "FotuUq_tag",
|
|
414
406
|
"toneSky": "FotuUq_toneSky",
|
|
415
407
|
"toneAmber": "FotuUq_toneAmber",
|
|
416
|
-
"
|
|
408
|
+
"toneLime": "FotuUq_toneLime",
|
|
409
|
+
"toneRose": "FotuUq_toneRose",
|
|
410
|
+
"toneOrange": "FotuUq_toneOrange",
|
|
417
411
|
"ratioBase": "FotuUq_ratioBase",
|
|
418
412
|
"toneViolet": "FotuUq_toneViolet",
|
|
419
413
|
"toneTeal": "FotuUq_toneTeal",
|
|
420
|
-
"
|
|
414
|
+
"ratioPricey": "FotuUq_ratioPricey",
|
|
415
|
+
"toneIndigo": "FotuUq_toneIndigo",
|
|
416
|
+
"ratioCheap": "FotuUq_ratioCheap",
|
|
417
|
+
"tag": "FotuUq_tag",
|
|
418
|
+
"ratioChip": "FotuUq_ratioChip",
|
|
419
|
+
"toneEmerald": "FotuUq_toneEmerald",
|
|
420
|
+
"toneFuchsia": "FotuUq_toneFuchsia"
|
|
421
421
|
};
|
|
422
422
|
//#endregion
|
|
423
423
|
//#region src/client/group-tags.tsx
|
|
@@ -472,39 +472,39 @@ window.__ModuleLoader__.load({
|
|
|
472
472
|
document.head.appendChild(tag);
|
|
473
473
|
}
|
|
474
474
|
var ModelGroupSelect_module_css_default = {
|
|
475
|
-
"groups": "_2pt-bW_groups",
|
|
476
|
-
"toast": "_2pt-bW_toast",
|
|
477
|
-
"cellValue": "_2pt-bW_cellValue",
|
|
478
|
-
"modelOption": "_2pt-bW_modelOption",
|
|
479
|
-
"searchClear": "_2pt-bW_searchClear",
|
|
480
475
|
"menu": "_2pt-bW_menu",
|
|
481
|
-
"
|
|
482
|
-
"
|
|
476
|
+
"triggerEffort": "_2pt-bW_triggerEffort",
|
|
477
|
+
"option": "_2pt-bW_option",
|
|
478
|
+
"error": "_2pt-bW_error",
|
|
479
|
+
"chevron": "_2pt-bW_chevron",
|
|
483
480
|
"groupInline": "_2pt-bW_groupInline",
|
|
481
|
+
"empty": "_2pt-bW_empty",
|
|
482
|
+
"cellChevron": "_2pt-bW_cellChevron",
|
|
483
|
+
"searchClear": "_2pt-bW_searchClear",
|
|
484
|
+
"groups": "_2pt-bW_groups",
|
|
485
|
+
"triggerLabel": "_2pt-bW_triggerLabel",
|
|
486
|
+
"cellValue": "_2pt-bW_cellValue",
|
|
484
487
|
"search": "_2pt-bW_search",
|
|
485
|
-
"optionCopy": "_2pt-bW_optionCopy",
|
|
486
488
|
"optionTrailing": "_2pt-bW_optionTrailing",
|
|
487
|
-
"
|
|
488
|
-
"
|
|
489
|
-
"triggerLabel": "_2pt-bW_triggerLabel",
|
|
490
|
-
"groupOptionLabel": "_2pt-bW_groupOptionLabel",
|
|
491
|
-
"root": "_2pt-bW_root",
|
|
492
|
-
"trigger": "_2pt-bW_trigger",
|
|
493
|
-
"error": "_2pt-bW_error",
|
|
489
|
+
"groupName": "_2pt-bW_groupName",
|
|
490
|
+
"optionCopy": "_2pt-bW_optionCopy",
|
|
494
491
|
"warning": "_2pt-bW_warning",
|
|
495
|
-
"
|
|
496
|
-
"triggerEffort": "_2pt-bW_triggerEffort",
|
|
492
|
+
"modelOption": "_2pt-bW_modelOption",
|
|
497
493
|
"triggerIcon": "_2pt-bW_triggerIcon",
|
|
498
|
-
"
|
|
499
|
-
"option": "_2pt-bW_option",
|
|
500
|
-
"cellLabel": "_2pt-bW_cellLabel",
|
|
501
|
-
"optionActive": "_2pt-bW_optionActive",
|
|
502
|
-
"modelName": "_2pt-bW_modelName",
|
|
494
|
+
"trigger": "_2pt-bW_trigger",
|
|
503
495
|
"retry": "_2pt-bW_retry",
|
|
496
|
+
"variantCount": "_2pt-bW_variantCount",
|
|
497
|
+
"cell": "_2pt-bW_cell",
|
|
498
|
+
"root": "_2pt-bW_root",
|
|
499
|
+
"groupOptionLabel": "_2pt-bW_groupOptionLabel",
|
|
500
|
+
"status": "_2pt-bW_status",
|
|
501
|
+
"modelName": "_2pt-bW_modelName",
|
|
502
|
+
"toast": "_2pt-bW_toast",
|
|
503
|
+
"selected": "_2pt-bW_selected",
|
|
504
504
|
"check": "_2pt-bW_check",
|
|
505
|
-
"
|
|
506
|
-
"
|
|
507
|
-
"
|
|
505
|
+
"cellLabel": "_2pt-bW_cellLabel",
|
|
506
|
+
"searchRow": "_2pt-bW_searchRow",
|
|
507
|
+
"optionActive": "_2pt-bW_optionActive"
|
|
508
508
|
};
|
|
509
509
|
//#endregion
|
|
510
510
|
//#region src/client/ModelGroupSelect.tsx
|
|
@@ -1070,77 +1070,77 @@ window.__ModuleLoader__.load({
|
|
|
1070
1070
|
document.head.appendChild(tag);
|
|
1071
1071
|
}
|
|
1072
1072
|
var NearTokenSection_module_css_default = {
|
|
1073
|
-
"
|
|
1074
|
-
"
|
|
1075
|
-
"handle": "_02HI2q_handle",
|
|
1076
|
-
"button": "_02HI2q_button",
|
|
1077
|
-
"count": "_02HI2q_count",
|
|
1078
|
-
"intro": "_02HI2q_intro",
|
|
1079
|
-
"badgeOn": "_02HI2q_badgeOn",
|
|
1080
|
-
"voucherRow": "_02HI2q_voucherRow",
|
|
1081
|
-
"badge": "_02HI2q_badge",
|
|
1082
|
-
"metaCheck": "_02HI2q_metaCheck",
|
|
1083
|
-
"voucherAmount": "_02HI2q_voucherAmount",
|
|
1073
|
+
"row": "_02HI2q_row",
|
|
1074
|
+
"buttonPrimary": "_02HI2q_buttonPrimary",
|
|
1084
1075
|
"invite": "_02HI2q_invite",
|
|
1085
|
-
"
|
|
1086
|
-
"
|
|
1087
|
-
"
|
|
1076
|
+
"voucherEmpty": "_02HI2q_voucherEmpty",
|
|
1077
|
+
"cardToggle": "_02HI2q_cardToggle",
|
|
1078
|
+
"factLabel": "_02HI2q_factLabel",
|
|
1088
1079
|
"topupChipActive": "_02HI2q_topupChipActive",
|
|
1089
|
-
"
|
|
1090
|
-
"countPicked": "_02HI2q_countPicked",
|
|
1091
|
-
"section": "_02HI2q_section",
|
|
1092
|
-
"factValue": "_02HI2q_factValue",
|
|
1093
|
-
"metaField": "_02HI2q_metaField",
|
|
1094
|
-
"metaEditor": "_02HI2q_metaEditor",
|
|
1095
|
-
"toolbar": "_02HI2q_toolbar",
|
|
1080
|
+
"hint": "_02HI2q_hint",
|
|
1096
1081
|
"rowName": "_02HI2q_rowName",
|
|
1097
|
-
"rowRatio": "_02HI2q_rowRatio",
|
|
1098
|
-
"codeRow": "_02HI2q_codeRow",
|
|
1099
|
-
"link": "_02HI2q_link",
|
|
1100
|
-
"tipTitle": "_02HI2q_tipTitle",
|
|
1101
|
-
"fact": "_02HI2q_fact",
|
|
1102
|
-
"topupBar": "_02HI2q_topupBar",
|
|
1103
|
-
"search": "_02HI2q_search",
|
|
1104
|
-
"linkLine": "_02HI2q_linkLine",
|
|
1105
|
-
"metaInput": "_02HI2q_metaInput",
|
|
1106
|
-
"name": "_02HI2q_name",
|
|
1107
1082
|
"tipGroupName": "_02HI2q_tipGroupName",
|
|
1108
|
-
"
|
|
1109
|
-
"
|
|
1110
|
-
"
|
|
1083
|
+
"name": "_02HI2q_name",
|
|
1084
|
+
"facts": "_02HI2q_facts",
|
|
1085
|
+
"metaBtnOn": "_02HI2q_metaBtnOn",
|
|
1086
|
+
"count": "_02HI2q_count",
|
|
1087
|
+
"countDot": "_02HI2q_countDot",
|
|
1088
|
+
"handle": "_02HI2q_handle",
|
|
1089
|
+
"rowMeta": "_02HI2q_rowMeta",
|
|
1111
1090
|
"topupChip": "_02HI2q_topupChip",
|
|
1112
|
-
"
|
|
1113
|
-
"
|
|
1114
|
-
"
|
|
1115
|
-
"
|
|
1116
|
-
"cardToggle": "_02HI2q_cardToggle",
|
|
1117
|
-
"label": "_02HI2q_label",
|
|
1118
|
-
"actions": "_02HI2q_actions",
|
|
1091
|
+
"metaInput": "_02HI2q_metaInput",
|
|
1092
|
+
"voucherGroup": "_02HI2q_voucherGroup",
|
|
1093
|
+
"linkLine": "_02HI2q_linkLine",
|
|
1094
|
+
"chevron": "_02HI2q_chevron",
|
|
1119
1095
|
"chevronOpen": "_02HI2q_chevronOpen",
|
|
1120
|
-
"
|
|
1121
|
-
"
|
|
1096
|
+
"voucherAmount": "_02HI2q_voucherAmount",
|
|
1097
|
+
"metaEditor": "_02HI2q_metaEditor",
|
|
1098
|
+
"badge": "_02HI2q_badge",
|
|
1122
1099
|
"topup": "_02HI2q_topup",
|
|
1123
|
-
"
|
|
1100
|
+
"select": "_02HI2q_select",
|
|
1101
|
+
"refresh": "_02HI2q_refresh",
|
|
1102
|
+
"form": "_02HI2q_form",
|
|
1103
|
+
"factValue": "_02HI2q_factValue",
|
|
1104
|
+
"link": "_02HI2q_link",
|
|
1105
|
+
"actions": "_02HI2q_actions",
|
|
1124
1106
|
"metaTitle": "_02HI2q_metaTitle",
|
|
1107
|
+
"section": "_02HI2q_section",
|
|
1108
|
+
"codeRow": "_02HI2q_codeRow",
|
|
1109
|
+
"title": "_02HI2q_title",
|
|
1110
|
+
"badgeOn": "_02HI2q_badgeOn",
|
|
1111
|
+
"autosave": "_02HI2q_autosave",
|
|
1112
|
+
"topupChips": "_02HI2q_topupChips",
|
|
1113
|
+
"tipRow": "_02HI2q_tipRow",
|
|
1114
|
+
"metaHint": "_02HI2q_metaHint",
|
|
1115
|
+
"code": "_02HI2q_code",
|
|
1116
|
+
"tipTitle": "_02HI2q_tipTitle",
|
|
1117
|
+
"valueRow": "_02HI2q_valueRow",
|
|
1125
1118
|
"voucherFact": "_02HI2q_voucherFact",
|
|
1126
|
-
"
|
|
1127
|
-
"
|
|
1128
|
-
"
|
|
1129
|
-
"
|
|
1130
|
-
"
|
|
1131
|
-
"chevron": "_02HI2q_chevron",
|
|
1119
|
+
"voucherList": "_02HI2q_voucherList",
|
|
1120
|
+
"linkRow": "_02HI2q_linkRow",
|
|
1121
|
+
"label": "_02HI2q_label",
|
|
1122
|
+
"metaCheck": "_02HI2q_metaCheck",
|
|
1123
|
+
"toolbar": "_02HI2q_toolbar",
|
|
1132
1124
|
"topupInput": "_02HI2q_topupInput",
|
|
1133
|
-
"
|
|
1134
|
-
"
|
|
1135
|
-
"
|
|
1136
|
-
"buttonPrimary": "_02HI2q_buttonPrimary",
|
|
1137
|
-
"hint": "_02HI2q_hint",
|
|
1138
|
-
"metaHint": "_02HI2q_metaHint",
|
|
1125
|
+
"metaIntro": "_02HI2q_metaIntro",
|
|
1126
|
+
"fact": "_02HI2q_fact",
|
|
1127
|
+
"search": "_02HI2q_search",
|
|
1139
1128
|
"list": "_02HI2q_list",
|
|
1140
|
-
"
|
|
1141
|
-
"
|
|
1142
|
-
"
|
|
1143
|
-
"
|
|
1129
|
+
"rowRatio": "_02HI2q_rowRatio",
|
|
1130
|
+
"card": "_02HI2q_card",
|
|
1131
|
+
"metaActions": "_02HI2q_metaActions",
|
|
1132
|
+
"metaBtn": "_02HI2q_metaBtn",
|
|
1133
|
+
"metaLabel": "_02HI2q_metaLabel",
|
|
1134
|
+
"intro": "_02HI2q_intro",
|
|
1135
|
+
"button": "_02HI2q_button",
|
|
1136
|
+
"tipGroup": "_02HI2q_tipGroup",
|
|
1137
|
+
"tip": "_02HI2q_tip",
|
|
1138
|
+
"topupBar": "_02HI2q_topupBar",
|
|
1139
|
+
"voucherRow": "_02HI2q_voucherRow",
|
|
1140
|
+
"countPicked": "_02HI2q_countPicked",
|
|
1141
|
+
"metaField": "_02HI2q_metaField",
|
|
1142
|
+
"notice": "_02HI2q_notice",
|
|
1143
|
+
"cardHead": "_02HI2q_cardHead"
|
|
1144
1144
|
};
|
|
1145
1145
|
//#endregion
|
|
1146
1146
|
//#region src/client/NearTokenSection.tsx
|
package/lib/index.js
CHANGED
|
@@ -2366,7 +2366,10 @@ function serializeRequest$3(options, model, images = /* @__PURE__ */ new Map())
|
|
|
2366
2366
|
const affinityKey = sessionKeyOf(options);
|
|
2367
2367
|
if (affinityKey !== void 0) body.metadata = { user_id: affinityKey };
|
|
2368
2368
|
if (options.reasoningEffort !== void 0) {
|
|
2369
|
-
body.thinking = {
|
|
2369
|
+
body.thinking = {
|
|
2370
|
+
type: "adaptive",
|
|
2371
|
+
display: "summarized"
|
|
2372
|
+
};
|
|
2370
2373
|
body.output_config = { effort: claudeEffort(options.reasoningEffort) };
|
|
2371
2374
|
}
|
|
2372
2375
|
if (options.maxTokens !== void 0) body.max_tokens = options.maxTokens;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-neartoken",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -42,13 +42,6 @@
|
|
|
42
42
|
"platform": "web"
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
|
-
"scripts": {
|
|
46
|
-
"build": "tsc -p tsconfig.build-host.json && tsc -p tsconfig.build-client.json && tsdown",
|
|
47
|
-
"bundle": "tsdown",
|
|
48
|
-
"watch": "tsdown --watch",
|
|
49
|
-
"typecheck": "tsc -p tsconfig.host.json --noEmit && tsc -p tsconfig.client.json --noEmit",
|
|
50
|
-
"test": "vitest run"
|
|
51
|
-
},
|
|
52
45
|
"peerDependencies": {
|
|
53
46
|
"@deepseek-ai/cordis": "~4.0.5-alpha.2",
|
|
54
47
|
"@deepseek-ai/dsh-api-remotes": "^0.2.1-alpha.5",
|
|
@@ -173,5 +166,12 @@
|
|
|
173
166
|
"tsdown": "^0.22.2",
|
|
174
167
|
"typescript": "^5.9.0",
|
|
175
168
|
"vitest": "^4.1.11"
|
|
169
|
+
},
|
|
170
|
+
"scripts": {
|
|
171
|
+
"build": "tsc -p tsconfig.build-host.json && tsc -p tsconfig.build-client.json && tsdown",
|
|
172
|
+
"bundle": "tsdown",
|
|
173
|
+
"watch": "tsdown --watch",
|
|
174
|
+
"typecheck": "tsc -p tsconfig.host.json --noEmit && tsc -p tsconfig.client.json --noEmit",
|
|
175
|
+
"test": "vitest run"
|
|
176
176
|
}
|
|
177
|
-
}
|
|
177
|
+
}
|