dsh-neartoken 0.19.0 → 0.19.2

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 CHANGED
@@ -59,6 +59,8 @@
59
59
 
60
60
  分组路由按同一文档:请求头 `x-neartoken-group` 的值是 `/api/pricing` 的 `group_refs` 给出的 **`#<id>`**(纯 ASCII),分组名只用于展示;某分组没有 ref 时不发该头,按令牌自身分组路由。
61
61
 
62
+ 模型选择器里的分组是**显式选择**:换模型时先保留当前分组;新模型不在该分组时,按分组名上的档位标签(`[低价]` / `[满血]` / `[官key]` 等)就近匹配同一档位的分组,而不是落回站点目录里的第一个分组——那一个往往是倍率最高的。跨模型族(`[低价] DeepSeek` → GPT)也按标签匹配。
63
+
62
64
  ## 数据概览(消耗 / Token / 模型堆积)
63
65
 
64
66
  账户卡片下方是「数据概览」:窗口内的消耗金额(括注当前余额)、窗口内的 Token 数,以及按模型堆积的面积图。右上角的「日 / 周 / 月」切换整个窗口 —— 桶宽由站点给,插件不自己造桶:
package/lib/client.js CHANGED
@@ -399,6 +399,32 @@ window.__ModuleLoader__.load({
399
399
  }));
400
400
  }
401
401
  /**
402
+ * Fold one group name into the badge texts that spell its tier out.
403
+ * @param group - a group name, e.g. `[低价][备用] GPT Pro`.
404
+ * @returns the badge texts, trimmed and lowercased for comparison.
405
+ */
406
+ function badgeTexts(group) {
407
+ return parseGroupLabel(group).badges.map((badge) => badge.text.trim().toLowerCase());
408
+ }
409
+ /**
410
+ * Score one candidate group against the tier the human already picked.
411
+ * The same badge SET is the closest thing to "the same group" when the site
412
+ * names each family's offering after its own family; otherwise the number of
413
+ * shared badges orders the candidates.
414
+ * @param current - badge texts of the group in use.
415
+ * @param candidate - the candidate's group name.
416
+ * @returns the sort keys, larger meaning closer.
417
+ */
418
+ function tierRank(current, candidate) {
419
+ const texts = badgeTexts(candidate);
420
+ const set = new Set(texts);
421
+ const shared = current.filter((text) => set.has(text)).length;
422
+ return {
423
+ same: shared === current.length && set.size === current.length,
424
+ shared
425
+ };
426
+ }
427
+ /**
402
428
  * Pick the variant a model row should route to.
403
429
  * @param option - the row being chosen.
404
430
  * @param preferredProvider - the currently selected provider, kept when it offers the model.
@@ -408,7 +434,15 @@ window.__ModuleLoader__.load({
408
434
  function chooseVariant(option, preferredProvider, preferredGroup) {
409
435
  const local = option.variants.filter((variant) => variant.provider === preferredProvider);
410
436
  const pool = local.length > 0 ? local : option.variants;
411
- return pool.find((variant) => variant.group === preferredGroup) ?? pool[0];
437
+ const exact = pool.find((variant) => variant.group === preferredGroup);
438
+ if (exact !== void 0) return exact;
439
+ const current = preferredGroup === void 0 ? [] : badgeTexts(preferredGroup);
440
+ if (current.length === 0) return pool[0];
441
+ return pool.map((variant, index) => ({
442
+ variant,
443
+ index,
444
+ rank: tierRank(current, variant.group ?? "")
445
+ })).toSorted((left, right) => Number(right.rank.same) - Number(left.rank.same) || right.rank.shared - left.rank.shared || left.index - right.index)[0]?.variant;
412
446
  }
413
447
  //#endregion
414
448
  //#region \0dsh-css:D:\Projects\deepseek-harness\dsh-neartoken\src\client\group-tags.module.css.mjs
@@ -422,23 +456,23 @@ window.__ModuleLoader__.load({
422
456
  document.head.appendChild(tag);
423
457
  }
424
458
  var group_tags_module_css_default = {
459
+ "toneIndigo": "FotuUq_toneIndigo",
425
460
  "toneLime": "FotuUq_toneLime",
426
- "ratioCheap": "FotuUq_ratioCheap",
427
- "ratioPricey": "FotuUq_ratioPricey",
428
461
  "toneRose": "FotuUq_toneRose",
429
- "toneIndigo": "FotuUq_toneIndigo",
430
- "tonePink": "FotuUq_tonePink",
431
- "toneSky": "FotuUq_toneSky",
432
- "toneTeal": "FotuUq_toneTeal",
433
462
  "toneEmerald": "FotuUq_toneEmerald",
434
- "toneAmber": "FotuUq_toneAmber",
435
- "toneViolet": "FotuUq_toneViolet",
436
- "tag": "FotuUq_tag",
437
- "toneFuchsia": "FotuUq_toneFuchsia",
438
463
  "ratioChip": "FotuUq_ratioChip",
464
+ "toneFuchsia": "FotuUq_toneFuchsia",
439
465
  "toneOrange": "FotuUq_toneOrange",
440
- "ratioBase": "FotuUq_ratioBase",
441
- "toneCyan": "FotuUq_toneCyan"
466
+ "tag": "FotuUq_tag",
467
+ "toneViolet": "FotuUq_toneViolet",
468
+ "toneSky": "FotuUq_toneSky",
469
+ "toneAmber": "FotuUq_toneAmber",
470
+ "ratioPricey": "FotuUq_ratioPricey",
471
+ "ratioCheap": "FotuUq_ratioCheap",
472
+ "toneTeal": "FotuUq_toneTeal",
473
+ "toneCyan": "FotuUq_toneCyan",
474
+ "tonePink": "FotuUq_tonePink",
475
+ "ratioBase": "FotuUq_ratioBase"
442
476
  };
443
477
  //#endregion
444
478
  //#region src/client/group-tags.tsx
@@ -493,39 +527,39 @@ window.__ModuleLoader__.load({
493
527
  document.head.appendChild(tag);
494
528
  }
495
529
  var ModelGroupSelect_module_css_default = {
496
- "check": "_2pt-bW_check",
497
- "variantCount": "_2pt-bW_variantCount",
498
- "optionCopy": "_2pt-bW_optionCopy",
499
- "search": "_2pt-bW_search",
500
- "groupOptionLabel": "_2pt-bW_groupOptionLabel",
501
- "cell": "_2pt-bW_cell",
502
- "chevron": "_2pt-bW_chevron",
503
- "menu": "_2pt-bW_menu",
530
+ "triggerEffort": "_2pt-bW_triggerEffort",
531
+ "cellLabel": "_2pt-bW_cellLabel",
532
+ "groups": "_2pt-bW_groups",
504
533
  "modelName": "_2pt-bW_modelName",
534
+ "groupName": "_2pt-bW_groupName",
505
535
  "searchRow": "_2pt-bW_searchRow",
536
+ "retry": "_2pt-bW_retry",
537
+ "empty": "_2pt-bW_empty",
506
538
  "triggerLabel": "_2pt-bW_triggerLabel",
507
- "cellChevron": "_2pt-bW_cellChevron",
508
- "triggerEffort": "_2pt-bW_triggerEffort",
509
539
  "status": "_2pt-bW_status",
510
- "searchClear": "_2pt-bW_searchClear",
511
- "selected": "_2pt-bW_selected",
512
- "optionActive": "_2pt-bW_optionActive",
513
- "groupInline": "_2pt-bW_groupInline",
514
- "retry": "_2pt-bW_retry",
515
- "triggerIcon": "_2pt-bW_triggerIcon",
516
- "error": "_2pt-bW_error",
517
- "root": "_2pt-bW_root",
540
+ "chevron": "_2pt-bW_chevron",
541
+ "search": "_2pt-bW_search",
518
542
  "warning": "_2pt-bW_warning",
519
- "modelOption": "_2pt-bW_modelOption",
520
543
  "option": "_2pt-bW_option",
544
+ "cellValue": "_2pt-bW_cellValue",
545
+ "variantCount": "_2pt-bW_variantCount",
546
+ "cellChevron": "_2pt-bW_cellChevron",
547
+ "selected": "_2pt-bW_selected",
548
+ "triggerIcon": "_2pt-bW_triggerIcon",
549
+ "searchClear": "_2pt-bW_searchClear",
550
+ "cell": "_2pt-bW_cell",
551
+ "groupOptionLabel": "_2pt-bW_groupOptionLabel",
521
552
  "optionTrailing": "_2pt-bW_optionTrailing",
522
- "groupName": "_2pt-bW_groupName",
523
553
  "toast": "_2pt-bW_toast",
524
- "empty": "_2pt-bW_empty",
525
- "groups": "_2pt-bW_groups",
526
- "cellValue": "_2pt-bW_cellValue",
554
+ "groupInline": "_2pt-bW_groupInline",
555
+ "modelOption": "_2pt-bW_modelOption",
556
+ "check": "_2pt-bW_check",
557
+ "optionCopy": "_2pt-bW_optionCopy",
527
558
  "trigger": "_2pt-bW_trigger",
528
- "cellLabel": "_2pt-bW_cellLabel"
559
+ "menu": "_2pt-bW_menu",
560
+ "error": "_2pt-bW_error",
561
+ "root": "_2pt-bW_root",
562
+ "optionActive": "_2pt-bW_optionActive"
529
563
  };
530
564
  //#endregion
531
565
  //#region src/client/ModelGroupSelect.tsx
@@ -1130,107 +1164,107 @@ window.__ModuleLoader__.load({
1130
1164
  document.head.appendChild(tag);
1131
1165
  }
1132
1166
  var NearTokenSection_module_css_default = {
1133
- "metaTitle": "_02HI2q_metaTitle",
1134
- "handle": "_02HI2q_handle",
1135
- "linkRow": "_02HI2q_linkRow",
1136
- "topupBar": "_02HI2q_topupBar",
1137
- "topupChipActive": "_02HI2q_topupChipActive",
1138
- "topupInput": "_02HI2q_topupInput",
1139
- "voucherGroup": "_02HI2q_voucherGroup",
1140
- "hint": "_02HI2q_hint",
1141
- "tip": "_02HI2q_tip",
1142
- "plot": "_02HI2q_plot",
1143
- "tally": "_02HI2q_tally",
1144
- "segment": "_02HI2q_segment",
1145
1167
  "voucherEmpty": "_02HI2q_voucherEmpty",
1146
- "label": "_02HI2q_label",
1147
- "plotRow": "_02HI2q_plotRow",
1168
+ "row": "_02HI2q_row",
1169
+ "notice": "_02HI2q_notice",
1148
1170
  "series0": "_02HI2q_series0",
1149
- "hit": "_02HI2q_hit",
1150
- "topup": "_02HI2q_topup",
1151
- "metaBtn": "_02HI2q_metaBtn",
1152
- "rowMeta": "_02HI2q_rowMeta",
1153
- "legendName": "_02HI2q_legendName",
1154
- "chevron": "_02HI2q_chevron",
1155
- "title": "_02HI2q_title",
1171
+ "series5": "_02HI2q_series5",
1172
+ "voucherList": "_02HI2q_voucherList",
1173
+ "label": "_02HI2q_label",
1174
+ "tally": "_02HI2q_tally",
1175
+ "metaLabel": "_02HI2q_metaLabel",
1156
1176
  "badgeOn": "_02HI2q_badgeOn",
1157
- "name": "_02HI2q_name",
1158
- "rowName": "_02HI2q_rowName",
1159
- "axisRow": "_02HI2q_axisRow",
1160
- "metaHead": "_02HI2q_metaHead",
1161
1177
  "metaChecks": "_02HI2q_metaChecks",
1162
- "toolbar": "_02HI2q_toolbar",
1163
- "voucherFact": "_02HI2q_voucherFact",
1164
- "axisLabel": "_02HI2q_axisLabel",
1165
- "series2": "_02HI2q_series2",
1178
+ "metaCheck": "_02HI2q_metaCheck",
1179
+ "rowMeta": "_02HI2q_rowMeta",
1180
+ "rowRatio": "_02HI2q_rowRatio",
1166
1181
  "form": "_02HI2q_form",
1167
- "topupChip": "_02HI2q_topupChip",
1168
- "metaActions": "_02HI2q_metaActions",
1182
+ "cardHead": "_02HI2q_cardHead",
1183
+ "linkLine": "_02HI2q_linkLine",
1184
+ "metaBtn": "_02HI2q_metaBtn",
1185
+ "metaField": "_02HI2q_metaField",
1186
+ "search": "_02HI2q_search",
1187
+ "tipGroup": "_02HI2q_tipGroup",
1188
+ "topup": "_02HI2q_topup",
1189
+ "title": "_02HI2q_title",
1190
+ "cardToggle": "_02HI2q_cardToggle",
1191
+ "countPicked": "_02HI2q_countPicked",
1192
+ "factValue": "_02HI2q_factValue",
1193
+ "metaBtnOn": "_02HI2q_metaBtnOn",
1194
+ "select": "_02HI2q_select",
1195
+ "axisLabel": "_02HI2q_axisLabel",
1196
+ "series3": "_02HI2q_series3",
1197
+ "voucherFact": "_02HI2q_voucherFact",
1198
+ "factLabel": "_02HI2q_factLabel",
1199
+ "linkRow": "_02HI2q_linkRow",
1200
+ "facts": "_02HI2q_facts",
1201
+ "link": "_02HI2q_link",
1169
1202
  "topupChips": "_02HI2q_topupChips",
1203
+ "buttonSmall": "_02HI2q_buttonSmall",
1204
+ "rowName": "_02HI2q_rowName",
1205
+ "voucherRow": "_02HI2q_voucherRow",
1206
+ "tipRow": "_02HI2q_tipRow",
1207
+ "tipGroupName": "_02HI2q_tipGroupName",
1208
+ "badge": "_02HI2q_badge",
1209
+ "refresh": "_02HI2q_refresh",
1170
1210
  "metaIntro": "_02HI2q_metaIntro",
1171
- "chart": "_02HI2q_chart",
1172
- "search": "_02HI2q_search",
1173
- "swatch": "_02HI2q_swatch",
1174
- "fact": "_02HI2q_fact",
1175
- "voucherList": "_02HI2q_voucherList",
1176
1211
  "count": "_02HI2q_count",
1177
- "legendCost": "_02HI2q_legendCost",
1178
- "code": "_02HI2q_code",
1212
+ "metaInput": "_02HI2q_metaInput",
1213
+ "topupInput": "_02HI2q_topupInput",
1179
1214
  "chevronOpen": "_02HI2q_chevronOpen",
1180
- "gridLine": "_02HI2q_gridLine",
1181
- "metaEditor": "_02HI2q_metaEditor",
1182
- "countDot": "_02HI2q_countDot",
1183
- "card": "_02HI2q_card",
1184
- "refresh": "_02HI2q_refresh",
1215
+ "metaActions": "_02HI2q_metaActions",
1216
+ "segment": "_02HI2q_segment",
1217
+ "codeRow": "_02HI2q_codeRow",
1218
+ "segmentOn": "_02HI2q_segmentOn",
1219
+ "yScale": "_02HI2q_yScale",
1220
+ "chevron": "_02HI2q_chevron",
1185
1221
  "valueRow": "_02HI2q_valueRow",
1186
- "select": "_02HI2q_select",
1187
- "intro": "_02HI2q_intro",
1188
- "metaBtnOn": "_02HI2q_metaBtnOn",
1189
1222
  "buttonPrimary": "_02HI2q_buttonPrimary",
1190
- "tipTitle": "_02HI2q_tipTitle",
1191
- "factValue": "_02HI2q_factValue",
1223
+ "topupBar": "_02HI2q_topupBar",
1224
+ "intro": "_02HI2q_intro",
1192
1225
  "autosave": "_02HI2q_autosave",
1193
- "actions": "_02HI2q_actions",
1194
- "tipGroup": "_02HI2q_tipGroup",
1195
- "row": "_02HI2q_row",
1196
- "series4": "_02HI2q_series4",
1197
- "codeRow": "_02HI2q_codeRow",
1198
- "badge": "_02HI2q_badge",
1199
- "cardHead": "_02HI2q_cardHead",
1200
- "metaField": "_02HI2q_metaField",
1201
- "section": "_02HI2q_section",
1202
- "metaInput": "_02HI2q_metaInput",
1226
+ "tipTitle": "_02HI2q_tipTitle",
1227
+ "countDot": "_02HI2q_countDot",
1228
+ "topupChip": "_02HI2q_topupChip",
1203
1229
  "metaHint": "_02HI2q_metaHint",
1204
- "list": "_02HI2q_list",
1205
- "axis": "_02HI2q_axis",
1206
- "series3": "_02HI2q_series3",
1207
- "segmented": "_02HI2q_segmented",
1208
- "voucherAmount": "_02HI2q_voucherAmount",
1209
- "series5": "_02HI2q_series5",
1210
- "factLabel": "_02HI2q_factLabel",
1211
- "countPicked": "_02HI2q_countPicked",
1212
- "notice": "_02HI2q_notice",
1213
1230
  "plotPanel": "_02HI2q_plotPanel",
1231
+ "yTick": "_02HI2q_yTick",
1232
+ "plot": "_02HI2q_plot",
1233
+ "gridLine": "_02HI2q_gridLine",
1234
+ "fact": "_02HI2q_fact",
1235
+ "hit": "_02HI2q_hit",
1236
+ "metaEditor": "_02HI2q_metaEditor",
1237
+ "legendItem": "_02HI2q_legendItem",
1238
+ "handle": "_02HI2q_handle",
1239
+ "swatch": "_02HI2q_swatch",
1240
+ "series1": "_02HI2q_series1",
1241
+ "name": "_02HI2q_name",
1242
+ "legendName": "_02HI2q_legendName",
1243
+ "series2": "_02HI2q_series2",
1214
1244
  "invite": "_02HI2q_invite",
1215
- "rowRatio": "_02HI2q_rowRatio",
1245
+ "plotRow": "_02HI2q_plotRow",
1246
+ "metaTitle": "_02HI2q_metaTitle",
1247
+ "voucherAmount": "_02HI2q_voucherAmount",
1248
+ "axisRow": "_02HI2q_axisRow",
1216
1249
  "gridBase": "_02HI2q_gridBase",
1217
1250
  "legend": "_02HI2q_legend",
1218
- "voucherRow": "_02HI2q_voucherRow",
1219
- "buttonSmall": "_02HI2q_buttonSmall",
1220
- "segmentOn": "_02HI2q_segmentOn",
1221
- "tipGroupName": "_02HI2q_tipGroupName",
1222
- "metaLabel": "_02HI2q_metaLabel",
1223
- "facts": "_02HI2q_facts",
1224
- "yScale": "_02HI2q_yScale",
1225
- "legendItem": "_02HI2q_legendItem",
1251
+ "actions": "_02HI2q_actions",
1252
+ "axis": "_02HI2q_axis",
1253
+ "legendCost": "_02HI2q_legendCost",
1254
+ "toolbar": "_02HI2q_toolbar",
1255
+ "topupChipActive": "_02HI2q_topupChipActive",
1256
+ "tip": "_02HI2q_tip",
1226
1257
  "button": "_02HI2q_button",
1227
- "metaCheck": "_02HI2q_metaCheck",
1228
- "linkLine": "_02HI2q_linkLine",
1229
- "link": "_02HI2q_link",
1230
- "tipRow": "_02HI2q_tipRow",
1231
- "series1": "_02HI2q_series1",
1232
- "yTick": "_02HI2q_yTick",
1233
- "cardToggle": "_02HI2q_cardToggle"
1258
+ "section": "_02HI2q_section",
1259
+ "chart": "_02HI2q_chart",
1260
+ "voucherGroup": "_02HI2q_voucherGroup",
1261
+ "code": "_02HI2q_code",
1262
+ "list": "_02HI2q_list",
1263
+ "series4": "_02HI2q_series4",
1264
+ "hint": "_02HI2q_hint",
1265
+ "metaHead": "_02HI2q_metaHead",
1266
+ "segmented": "_02HI2q_segmented",
1267
+ "card": "_02HI2q_card"
1234
1268
  };
1235
1269
  //#endregion
1236
1270
  //#region src/client/NearTokenSection.tsx