@jxgame2020/dsh-token-quota 0.1.51 → 0.1.54
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/cordis.patch.yml +9 -0
- package/lib/client.js +131 -131
- package/lib/index.js +29 -5
- package/lib/types/index.js +43 -4
- package/package.json +5 -1
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Composition bundle for @jxgame2020/dsh-token-quota.
|
|
2
|
+
#
|
|
3
|
+
# The Harness plugin manager installs a package only when it declares
|
|
4
|
+
# `dsh.bundle` and ships this patch: the patch is what actually mounts the
|
|
5
|
+
# plugin into the profile's loader tree. Installing the package alone puts the
|
|
6
|
+
# code in node_modules; this row is what makes the Harness load it.
|
|
7
|
+
- insert:
|
|
8
|
+
- id: token-quota
|
|
9
|
+
name: '@jxgame2020/dsh-token-quota'
|
package/lib/client.js
CHANGED
|
@@ -132,7 +132,7 @@ window.__ModuleLoader__.load({
|
|
|
132
132
|
d.transcribe = settings;
|
|
133
133
|
},
|
|
134
134
|
setUpgrade: (d, upgrade) => {
|
|
135
|
-
const normalized = upgrade !== null && upgrade.latestVersion !== "" && upgrade.latestVersion !== "0.1.
|
|
135
|
+
const normalized = upgrade !== null && upgrade.latestVersion !== "" && upgrade.latestVersion !== "0.1.54" ? upgrade : null;
|
|
136
136
|
if (d.upgrade === null || d.upgrade.latestVersion !== normalized?.latestVersion) d.upgradeDismissed = false;
|
|
137
137
|
d.upgrade = normalized;
|
|
138
138
|
},
|
|
@@ -262,147 +262,147 @@ window.__ModuleLoader__.load({
|
|
|
262
262
|
document.head.appendChild(tag);
|
|
263
263
|
}
|
|
264
264
|
var TokenQuotaPanel_module_css_default = {
|
|
265
|
-
"
|
|
266
|
-
"
|
|
265
|
+
"panelDimStrong": "NPLLIq_panelDimStrong",
|
|
266
|
+
"balanceStateError": "NPLLIq_balanceStateError",
|
|
267
|
+
"noteNew": "NPLLIq_noteNew",
|
|
268
|
+
"rowHeader": "NPLLIq_rowHeader",
|
|
269
|
+
"balanceWinHeader": "NPLLIq_balanceWinHeader",
|
|
270
|
+
"balanceValueOk": "NPLLIq_balanceValueOk",
|
|
271
|
+
"balanceBarError": "NPLLIq_balanceBarError",
|
|
272
|
+
"dialogSection": "NPLLIq_dialogSection",
|
|
273
|
+
"monitorName": "NPLLIq_monitorName",
|
|
274
|
+
"logPagerBtn": "NPLLIq_logPagerBtn",
|
|
275
|
+
"headerText": "NPLLIq_headerText",
|
|
267
276
|
"fillWarn": "NPLLIq_fillWarn",
|
|
268
|
-
"
|
|
269
|
-
"
|
|
270
|
-
"tab": "NPLLIq_tab",
|
|
271
|
-
"fullNotice": "NPLLIq_fullNotice",
|
|
272
|
-
"balanceValueError": "NPLLIq_balanceValueError",
|
|
273
|
-
"upgradeCommands": "NPLLIq_upgradeCommands",
|
|
274
|
-
"balanceWin": "NPLLIq_balanceWin",
|
|
275
|
-
"balanceToggle": "NPLLIq_balanceToggle",
|
|
276
|
-
"notesBar": "NPLLIq_notesBar",
|
|
277
|
-
"keyRow": "NPLLIq_keyRow",
|
|
277
|
+
"logPagerInfo": "NPLLIq_logPagerInfo",
|
|
278
|
+
"upgradeCommand": "NPLLIq_upgradeCommand",
|
|
278
279
|
"input": "NPLLIq_input",
|
|
279
|
-
"
|
|
280
|
-
"logHeader": "NPLLIq_logHeader",
|
|
281
|
-
"subtitle": "NPLLIq_subtitle",
|
|
282
|
-
"body": "NPLLIq_body",
|
|
283
|
-
"balanceBarDim": "NPLLIq_balanceBarDim",
|
|
284
|
-
"upgradeHint": "NPLLIq_upgradeHint",
|
|
285
|
-
"panelDimStrong": "NPLLIq_panelDimStrong",
|
|
280
|
+
"dialogClose": "NPLLIq_dialogClose",
|
|
286
281
|
"title": "NPLLIq_title",
|
|
287
|
-
"
|
|
288
|
-
"
|
|
289
|
-
"
|
|
290
|
-
"
|
|
291
|
-
"
|
|
292
|
-
"
|
|
293
|
-
"settingsBtn": "NPLLIq_settingsBtn",
|
|
294
|
-
"dialogActions": "NPLLIq_dialogActions",
|
|
295
|
-
"balanceWinBody": "NPLLIq_balanceWinBody",
|
|
296
|
-
"resetRow": "NPLLIq_resetRow",
|
|
282
|
+
"dialogTitle": "NPLLIq_dialogTitle",
|
|
283
|
+
"tabLabel": "NPLLIq_tabLabel",
|
|
284
|
+
"logClearDialog": "NPLLIq_logClearDialog",
|
|
285
|
+
"dialogBtnPrimary": "NPLLIq_dialogBtnPrimary",
|
|
286
|
+
"logTable": "NPLLIq_logTable",
|
|
287
|
+
"dialogOverlay": "NPLLIq_dialogOverlay",
|
|
297
288
|
"balanceRowRefresh": "NPLLIq_balanceRowRefresh",
|
|
289
|
+
"panelDim": "NPLLIq_panelDim",
|
|
290
|
+
"header": "NPLLIq_header",
|
|
291
|
+
"dialogTabs": "NPLLIq_dialogTabs",
|
|
292
|
+
"noteWinGripBar": "NPLLIq_noteWinGripBar",
|
|
298
293
|
"upgradeClose": "NPLLIq_upgradeClose",
|
|
299
|
-
"
|
|
300
|
-
"
|
|
301
|
-
"
|
|
302
|
-
"logClearDate": "NPLLIq_logClearDate",
|
|
303
|
-
"headerText": "NPLLIq_headerText",
|
|
304
|
-
"dialogTitle": "NPLLIq_dialogTitle",
|
|
305
|
-
"upgradeBanner": "NPLLIq_upgradeBanner",
|
|
306
|
-
"monitorRow": "NPLLIq_monitorRow",
|
|
307
|
-
"dialogSection": "NPLLIq_dialogSection",
|
|
294
|
+
"noteWinResize": "NPLLIq_noteWinResize",
|
|
295
|
+
"resetRow": "NPLLIq_resetRow",
|
|
296
|
+
"noteWinTitleText": "NPLLIq_noteWinTitleText",
|
|
308
297
|
"checkUpdatesLabel": "NPLLIq_checkUpdatesLabel",
|
|
309
|
-
"
|
|
310
|
-
"
|
|
311
|
-
"balanceBarText": "NPLLIq_balanceBarText",
|
|
312
|
-
"noteWinText": "NPLLIq_noteWinText",
|
|
313
|
-
"balanceLastLine": "NPLLIq_balanceLastLine",
|
|
314
|
-
"notice": "NPLLIq_notice",
|
|
315
|
-
"logDialog": "NPLLIq_logDialog",
|
|
316
|
-
"monitorName": "NPLLIq_monitorName",
|
|
317
|
-
"balanceBarBadge": "NPLLIq_balanceBarBadge",
|
|
318
|
-
"logScroll": "NPLLIq_logScroll",
|
|
319
|
-
"settingsDialog": "NPLLIq_settingsDialog",
|
|
320
|
-
"noteChip": "NPLLIq_noteChip",
|
|
321
|
-
"noteMenuBackdrop": "NPLLIq_noteMenuBackdrop",
|
|
298
|
+
"version": "NPLLIq_version",
|
|
299
|
+
"noteMenu": "NPLLIq_noteMenu",
|
|
322
300
|
"copyBtn": "NPLLIq_copyBtn",
|
|
323
|
-
"
|
|
324
|
-
"
|
|
301
|
+
"checkBtn": "NPLLIq_checkBtn",
|
|
302
|
+
"monitorHint": "NPLLIq_monitorHint",
|
|
325
303
|
"checkErrorHint": "NPLLIq_checkErrorHint",
|
|
326
|
-
"
|
|
327
|
-
"fillOver": "NPLLIq_fillOver",
|
|
328
|
-
"balanceSortBtn": "NPLLIq_balanceSortBtn",
|
|
329
|
-
"rowName": "NPLLIq_rowName",
|
|
330
|
-
"settingsBtnActive": "NPLLIq_settingsBtnActive",
|
|
331
|
-
"logPagerPages": "NPLLIq_logPagerPages",
|
|
332
|
-
"balanceStateError": "NPLLIq_balanceStateError",
|
|
333
|
-
"balanceBarLow": "NPLLIq_balanceBarLow",
|
|
334
|
-
"logToolbar": "NPLLIq_logToolbar",
|
|
335
|
-
"balanceRow": "NPLLIq_balanceRow",
|
|
336
|
-
"dialogHint": "NPLLIq_dialogHint",
|
|
337
|
-
"noteWinTitle": "NPLLIq_noteWinTitle",
|
|
304
|
+
"save": "NPLLIq_save",
|
|
338
305
|
"logPageSizeSelect": "NPLLIq_logPageSizeSelect",
|
|
339
|
-
"rowHeader": "NPLLIq_rowHeader",
|
|
340
|
-
"versionNew": "NPLLIq_versionNew",
|
|
341
|
-
"balanceRowHeader": "NPLLIq_balanceRowHeader",
|
|
342
|
-
"logClearDialog": "NPLLIq_logClearDialog",
|
|
343
|
-
"dialogBody": "NPLLIq_dialogBody",
|
|
344
306
|
"balanceRefreshAll": "NPLLIq_balanceRefreshAll",
|
|
345
|
-
"
|
|
307
|
+
"noticeError": "NPLLIq_noticeError",
|
|
308
|
+
"rowDrag": "NPLLIq_rowDrag",
|
|
346
309
|
"monitorList": "NPLLIq_monitorList",
|
|
347
|
-
"
|
|
348
|
-
"
|
|
349
|
-
"
|
|
350
|
-
"
|
|
351
|
-
"
|
|
352
|
-
"
|
|
353
|
-
"
|
|
354
|
-
"
|
|
355
|
-
"
|
|
356
|
-
"
|
|
310
|
+
"keyRow": "NPLLIq_keyRow",
|
|
311
|
+
"notesBar": "NPLLIq_notesBar",
|
|
312
|
+
"fillIdle": "NPLLIq_fillIdle",
|
|
313
|
+
"balanceWinBody": "NPLLIq_balanceWinBody",
|
|
314
|
+
"checkUpdatesRow": "NPLLIq_checkUpdatesRow",
|
|
315
|
+
"balanceBarDim": "NPLLIq_balanceBarDim",
|
|
316
|
+
"balanceValueError": "NPLLIq_balanceValueError",
|
|
317
|
+
"balanceToggleOpen": "NPLLIq_balanceToggleOpen",
|
|
318
|
+
"balanceBarLow": "NPLLIq_balanceBarLow",
|
|
319
|
+
"selectBtn": "NPLLIq_selectBtn",
|
|
320
|
+
"tabIcon": "NPLLIq_tabIcon",
|
|
321
|
+
"subtitle": "NPLLIq_subtitle",
|
|
322
|
+
"panel": "NPLLIq_panel",
|
|
323
|
+
"upgradeCommands": "NPLLIq_upgradeCommands",
|
|
324
|
+
"resetSelect": "NPLLIq_resetSelect",
|
|
325
|
+
"notice": "NPLLIq_notice",
|
|
326
|
+
"logUsedCol": "NPLLIq_logUsedCol",
|
|
327
|
+
"keyBadgeOff": "NPLLIq_keyBadgeOff",
|
|
328
|
+
"logHeader": "NPLLIq_logHeader",
|
|
329
|
+
"monitorRow": "NPLLIq_monitorRow",
|
|
330
|
+
"logPagerControls": "NPLLIq_logPagerControls",
|
|
357
331
|
"row": "NPLLIq_row",
|
|
358
|
-
"
|
|
332
|
+
"balanceBarRefresh": "NPLLIq_balanceBarRefresh",
|
|
333
|
+
"gearBtn": "NPLLIq_gearBtn",
|
|
334
|
+
"versionNew": "NPLLIq_versionNew",
|
|
335
|
+
"switch": "NPLLIq_switch",
|
|
336
|
+
"balanceRowValue": "NPLLIq_balanceRowValue",
|
|
337
|
+
"keySaveBtn": "NPLLIq_keySaveBtn",
|
|
338
|
+
"keyError": "NPLLIq_keyError",
|
|
339
|
+
"headerActions": "NPLLIq_headerActions",
|
|
340
|
+
"noteWinCollapsed": "NPLLIq_noteWinCollapsed",
|
|
341
|
+
"balanceStateHint": "NPLLIq_balanceStateHint",
|
|
342
|
+
"upgradeBanner": "NPLLIq_upgradeBanner",
|
|
343
|
+
"balanceWinTitle": "NPLLIq_balanceWinTitle",
|
|
359
344
|
"dialogTab": "NPLLIq_dialogTab",
|
|
345
|
+
"noteChipOpen": "NPLLIq_noteChipOpen",
|
|
346
|
+
"noteWinBtn": "NPLLIq_noteWinBtn",
|
|
347
|
+
"noteChip": "NPLLIq_noteChip",
|
|
348
|
+
"rowMeta": "NPLLIq_rowMeta",
|
|
349
|
+
"logScroll": "NPLLIq_logScroll",
|
|
350
|
+
"noteMenuBackdrop": "NPLLIq_noteMenuBackdrop",
|
|
351
|
+
"bar": "NPLLIq_bar",
|
|
352
|
+
"balanceRowName": "NPLLIq_balanceRowName",
|
|
353
|
+
"copyBtnDone": "NPLLIq_copyBtnDone",
|
|
354
|
+
"logToolbar": "NPLLIq_logToolbar",
|
|
355
|
+
"balanceValueLow": "NPLLIq_balanceValueLow",
|
|
356
|
+
"balanceToggle": "NPLLIq_balanceToggle",
|
|
360
357
|
"logClearBtn": "NPLLIq_logClearBtn",
|
|
361
|
-
"
|
|
362
|
-
"
|
|
363
|
-
"noteNewPlus": "NPLLIq_noteNewPlus",
|
|
364
|
-
"controls": "NPLLIq_controls",
|
|
365
|
-
"dialogTabActive": "NPLLIq_dialogTabActive",
|
|
366
|
-
"headerActions": "NPLLIq_headerActions",
|
|
358
|
+
"body": "NPLLIq_body",
|
|
359
|
+
"rowDragging": "NPLLIq_rowDragging",
|
|
367
360
|
"dialogBtn": "NPLLIq_dialogBtn",
|
|
368
|
-
"
|
|
369
|
-
"
|
|
361
|
+
"logPagerPages": "NPLLIq_logPagerPages",
|
|
362
|
+
"logClearDate": "NPLLIq_logClearDate",
|
|
363
|
+
"logModelCol": "NPLLIq_logModelCol",
|
|
370
364
|
"noteWinBar": "NPLLIq_noteWinBar",
|
|
371
|
-
"
|
|
372
|
-
"
|
|
373
|
-
"
|
|
374
|
-
"
|
|
375
|
-
"
|
|
376
|
-
"
|
|
365
|
+
"balanceSortBtn": "NPLLIq_balanceSortBtn",
|
|
366
|
+
"logDialog": "NPLLIq_logDialog",
|
|
367
|
+
"noteMenuItem": "NPLLIq_noteMenuItem",
|
|
368
|
+
"tab": "NPLLIq_tab",
|
|
369
|
+
"noteWinText": "NPLLIq_noteWinText",
|
|
370
|
+
"logDayCol": "NPLLIq_logDayCol",
|
|
371
|
+
"keyBadgeOk": "NPLLIq_keyBadgeOk",
|
|
372
|
+
"controls": "NPLLIq_controls",
|
|
373
|
+
"balanceWin": "NPLLIq_balanceWin",
|
|
374
|
+
"settingsDialog": "NPLLIq_settingsDialog",
|
|
375
|
+
"balanceRow": "NPLLIq_balanceRow",
|
|
376
|
+
"balanceBarBadge": "NPLLIq_balanceBarBadge",
|
|
377
|
+
"dialogTabActive": "NPLLIq_dialogTabActive",
|
|
378
|
+
"dialogHeader": "NPLLIq_dialogHeader",
|
|
377
379
|
"upgradeBannerText": "NPLLIq_upgradeBannerText",
|
|
378
|
-
"
|
|
379
|
-
"
|
|
380
|
-
"logModelCol": "NPLLIq_logModelCol",
|
|
381
|
-
"logPagerInfo": "NPLLIq_logPagerInfo",
|
|
382
|
-
"noteMenu": "NPLLIq_noteMenu",
|
|
380
|
+
"collapse": "NPLLIq_collapse",
|
|
381
|
+
"rowName": "NPLLIq_rowName",
|
|
383
382
|
"noteWin": "NPLLIq_noteWin",
|
|
384
|
-
"
|
|
385
|
-
"
|
|
386
|
-
"noteNew": "NPLLIq_noteNew",
|
|
387
|
-
"resetSelect": "NPLLIq_resetSelect",
|
|
388
|
-
"selectBtn": "NPLLIq_selectBtn",
|
|
389
|
-
"dialogLabel": "NPLLIq_dialogLabel",
|
|
383
|
+
"logSearch": "NPLLIq_logSearch",
|
|
384
|
+
"balanceBar": "NPLLIq_balanceBar",
|
|
390
385
|
"upgradeBannerFlash": "NPLLIq_upgradeBannerFlash",
|
|
391
|
-
"
|
|
392
|
-
"
|
|
393
|
-
"
|
|
394
|
-
"
|
|
395
|
-
"
|
|
396
|
-
"
|
|
397
|
-
"
|
|
398
|
-
"
|
|
399
|
-
"
|
|
400
|
-
"
|
|
401
|
-
"
|
|
402
|
-
"
|
|
403
|
-
"
|
|
404
|
-
"
|
|
405
|
-
"
|
|
386
|
+
"currentBadge": "NPLLIq_currentBadge",
|
|
387
|
+
"logPager": "NPLLIq_logPager",
|
|
388
|
+
"dialogLabel": "NPLLIq_dialogLabel",
|
|
389
|
+
"fillOver": "NPLLIq_fillOver",
|
|
390
|
+
"dialogActions": "NPLLIq_dialogActions",
|
|
391
|
+
"noteNewPlus": "NPLLIq_noteNewPlus",
|
|
392
|
+
"upgradeCommandRow": "NPLLIq_upgradeCommandRow",
|
|
393
|
+
"fullNotice": "NPLLIq_fullNotice",
|
|
394
|
+
"dialogBody": "NPLLIq_dialogBody",
|
|
395
|
+
"dialog": "NPLLIq_dialog",
|
|
396
|
+
"rowDropTarget": "NPLLIq_rowDropTarget",
|
|
397
|
+
"radioRow": "NPLLIq_radioRow",
|
|
398
|
+
"balanceBarText": "NPLLIq_balanceBarText",
|
|
399
|
+
"upgradeHint": "NPLLIq_upgradeHint",
|
|
400
|
+
"settingsBtn": "NPLLIq_settingsBtn",
|
|
401
|
+
"balanceLastLine": "NPLLIq_balanceLastLine",
|
|
402
|
+
"settingsBtnActive": "NPLLIq_settingsBtnActive",
|
|
403
|
+
"dialogHint": "NPLLIq_dialogHint",
|
|
404
|
+
"noteWinTitle": "NPLLIq_noteWinTitle",
|
|
405
|
+
"balanceRowHeader": "NPLLIq_balanceRowHeader"
|
|
406
406
|
};
|
|
407
407
|
//#endregion
|
|
408
408
|
//#region lib/types/client/TokenQuotaPanel.js
|
|
@@ -1139,13 +1139,13 @@ window.__ModuleLoader__.load({
|
|
|
1139
1139
|
title: t("upgradeAvailableHint"),
|
|
1140
1140
|
children: [
|
|
1141
1141
|
"v",
|
|
1142
|
-
"0.1.
|
|
1142
|
+
"0.1.54",
|
|
1143
1143
|
" → v",
|
|
1144
1144
|
upgrade.latestVersion
|
|
1145
1145
|
]
|
|
1146
1146
|
}) : (0, react_jsx_runtime.jsxs)("span", {
|
|
1147
1147
|
className: TokenQuotaPanel_module_css_default.version,
|
|
1148
|
-
children: ["v", "0.1.
|
|
1148
|
+
children: ["v", "0.1.54"]
|
|
1149
1149
|
})]
|
|
1150
1150
|
})
|
|
1151
1151
|
}),
|
|
@@ -3005,12 +3005,12 @@ window.__ModuleLoader__.load({
|
|
|
3005
3005
|
document.head.appendChild(tag);
|
|
3006
3006
|
}
|
|
3007
3007
|
var mic_module_css_default = {
|
|
3008
|
-
"
|
|
3008
|
+
"micWrap": "KCoVpa_micWrap",
|
|
3009
3009
|
"micPulse": "KCoVpa_micPulse",
|
|
3010
|
-
"micBtn": "KCoVpa_micBtn",
|
|
3011
3010
|
"micErr": "KCoVpa_micErr",
|
|
3012
|
-
"
|
|
3011
|
+
"micBtn": "KCoVpa_micBtn",
|
|
3013
3012
|
"micBusy": "KCoVpa_micBusy",
|
|
3013
|
+
"micRec": "KCoVpa_micRec",
|
|
3014
3014
|
"micErrTip": "KCoVpa_micErrTip"
|
|
3015
3015
|
};
|
|
3016
3016
|
//#endregion
|
|
@@ -3205,12 +3205,12 @@ window.__ModuleLoader__.load({
|
|
|
3205
3205
|
document.head.appendChild(tag);
|
|
3206
3206
|
}
|
|
3207
3207
|
var TokenQuotaStash_module_css_default = {
|
|
3208
|
-
"
|
|
3208
|
+
"stashRow": "x_tEcG_stashRow",
|
|
3209
3209
|
"stashTip": "x_tEcG_stashTip",
|
|
3210
3210
|
"stashChip": "x_tEcG_stashChip",
|
|
3211
|
-
"
|
|
3211
|
+
"selBtn": "x_tEcG_selBtn",
|
|
3212
3212
|
"selPopup": "x_tEcG_selPopup",
|
|
3213
|
-
"
|
|
3213
|
+
"selDivider": "x_tEcG_selDivider"
|
|
3214
3214
|
};
|
|
3215
3215
|
//#endregion
|
|
3216
3216
|
//#region lib/types/client/TokenQuotaStash.js
|
package/lib/index.js
CHANGED
|
@@ -278,6 +278,16 @@ function usageTokens(usage) {
|
|
|
278
278
|
const DEEPSEEK_BALANCE_HOST = "api.deepseek.com";
|
|
279
279
|
/** TeamoRouter's host; its model and billing endpoints share this domain. */
|
|
280
280
|
const TEAMOROUTER_HOST = "teamorouter.cn";
|
|
281
|
+
/**
|
|
282
|
+
* Credential reference each family's adapter falls back to when the provider
|
|
283
|
+
* entry declares no `apiKeyEnv` (e.g. `llm-deepseek`, whose adapter resolves
|
|
284
|
+
* DEEPSEEK_API_KEY internally). Querying that same reference is what makes such
|
|
285
|
+
* a provider represent the same account the model calls are billed to.
|
|
286
|
+
*/
|
|
287
|
+
const DEFAULT_BALANCE_KEY_ENV = {
|
|
288
|
+
deepseek: "DEEPSEEK_API_KEY",
|
|
289
|
+
teamorouter: "TEAMO_ROUTER_API_KEY"
|
|
290
|
+
};
|
|
281
291
|
/** Fallback currency per family, used before the first successful fetch. */
|
|
282
292
|
const BALANCE_DEFAULT_CURRENCY = {
|
|
283
293
|
deepseek: "CNY",
|
|
@@ -687,7 +697,7 @@ var TokenQuotaService = class TokenQuotaService extends Service {
|
|
|
687
697
|
return this.upgradeCheck;
|
|
688
698
|
}
|
|
689
699
|
async doRefreshUpgrade() {
|
|
690
|
-
const current = "0.1.
|
|
700
|
+
const current = "0.1.54";
|
|
691
701
|
let latest;
|
|
692
702
|
try {
|
|
693
703
|
const response = await fetch(REGISTRY_LATEST_URL, {
|
|
@@ -775,11 +785,21 @@ var TokenQuotaService = class TokenQuotaService extends Service {
|
|
|
775
785
|
const found = /* @__PURE__ */ new Map();
|
|
776
786
|
const llm = this.ctx.get("llm");
|
|
777
787
|
const configEditor = this.ctx.get("configEditor");
|
|
788
|
+
const profileOf = (row) => {
|
|
789
|
+
const layers = [
|
|
790
|
+
row.override,
|
|
791
|
+
row.inherited,
|
|
792
|
+
row.entry?.fiber?.config,
|
|
793
|
+
row.entry?.options?.config
|
|
794
|
+
];
|
|
795
|
+
for (const layer of layers) if (layer !== null && typeof layer === "object" && "providers" in layer) return layer;
|
|
796
|
+
for (const layer of layers) if (layer !== null && typeof layer === "object") return layer;
|
|
797
|
+
};
|
|
778
798
|
const liveConfigs = /* @__PURE__ */ new Map();
|
|
779
799
|
try {
|
|
780
800
|
for (const row of configEditor?.configuration() ?? []) {
|
|
781
|
-
const id = row.entry
|
|
782
|
-
if (id !== void 0) liveConfigs.set(id, row
|
|
801
|
+
const id = row.entry?.options?.id;
|
|
802
|
+
if (id !== void 0) liveConfigs.set(id, profileOf(row));
|
|
783
803
|
}
|
|
784
804
|
} catch {}
|
|
785
805
|
const fallback = () => ({
|
|
@@ -800,15 +820,19 @@ var TokenQuotaService = class TokenQuotaService extends Service {
|
|
|
800
820
|
const keyEnv = typeof record.apiKeyEnv === "string" && record.apiKeyEnv !== "" ? record.apiKeyEnv : void 0;
|
|
801
821
|
const baseURL = typeof record.baseURL === "string" && record.baseURL !== "" ? record.baseURL : void 0;
|
|
802
822
|
const kind = balanceKindOf(entry.provider, keyEnv, baseURL);
|
|
803
|
-
if (kind === void 0
|
|
823
|
+
if (kind === void 0) continue;
|
|
824
|
+
const balanceKeyEnv = keyEnv ?? DEFAULT_BALANCE_KEY_ENV[kind];
|
|
804
825
|
found.set(entry.provider, {
|
|
805
826
|
provider: entry.provider,
|
|
806
|
-
keyEnv,
|
|
827
|
+
keyEnv: balanceKeyEnv,
|
|
807
828
|
baseURL: baseURL ?? (kind === "deepseek" ? `https://${DEEPSEEK_BALANCE_HOST}` : `https://${TEAMOROUTER_HOST}`),
|
|
808
829
|
kind
|
|
809
830
|
});
|
|
810
831
|
} catch {}
|
|
811
832
|
if (found.size === 0) found.set("deepseek", fallback());
|
|
833
|
+
try {
|
|
834
|
+
this.ctx.logger?.info(`token-quota: balance sources = ${[...found.values()].map((source) => `${source.provider}(${source.kind})`).join(", ")}`);
|
|
835
|
+
} catch {}
|
|
812
836
|
return found;
|
|
813
837
|
}
|
|
814
838
|
/**
|
package/lib/types/index.js
CHANGED
|
@@ -283,6 +283,16 @@ function usageTokens(usage) {
|
|
|
283
283
|
const DEEPSEEK_BALANCE_HOST = 'api.deepseek.com';
|
|
284
284
|
/** TeamoRouter's host; its model and billing endpoints share this domain. */
|
|
285
285
|
const TEAMOROUTER_HOST = 'teamorouter.cn';
|
|
286
|
+
/**
|
|
287
|
+
* Credential reference each family's adapter falls back to when the provider
|
|
288
|
+
* entry declares no `apiKeyEnv` (e.g. `llm-deepseek`, whose adapter resolves
|
|
289
|
+
* DEEPSEEK_API_KEY internally). Querying that same reference is what makes such
|
|
290
|
+
* a provider represent the same account the model calls are billed to.
|
|
291
|
+
*/
|
|
292
|
+
const DEFAULT_BALANCE_KEY_ENV = {
|
|
293
|
+
deepseek: 'DEEPSEEK_API_KEY',
|
|
294
|
+
teamorouter: 'TEAMO_ROUTER_API_KEY',
|
|
295
|
+
};
|
|
286
296
|
/** Fallback currency per family, used before the first successful fetch. */
|
|
287
297
|
const BALANCE_DEFAULT_CURRENCY = {
|
|
288
298
|
deepseek: 'CNY',
|
|
@@ -850,12 +860,29 @@ export class TokenQuotaService extends Service {
|
|
|
850
860
|
// version dropped `settings.get(ns)`, so read the composed configuration
|
|
851
861
|
// once from the config editor and index it by profile entry id.
|
|
852
862
|
const configEditor = this.ctx.get('configEditor');
|
|
863
|
+
// Provider profiles live in another plugin entry's config (the profile's
|
|
864
|
+
// `providers` map). Which of the composed layers carries it depends on the
|
|
865
|
+
// deployment (user patch layer vs inherited base), so take the first layer
|
|
866
|
+
// that actually has a `providers` map and fall back to the entry's own
|
|
867
|
+
// config. Reading only one layer silently finds no providers at all.
|
|
868
|
+
const profileOf = (row) => {
|
|
869
|
+
const layers = [row.override, row.inherited, row.entry?.fiber?.config, row.entry?.options?.config];
|
|
870
|
+
for (const layer of layers) {
|
|
871
|
+
if (layer !== null && typeof layer === 'object' && 'providers' in layer)
|
|
872
|
+
return layer;
|
|
873
|
+
}
|
|
874
|
+
for (const layer of layers) {
|
|
875
|
+
if (layer !== null && typeof layer === 'object')
|
|
876
|
+
return layer;
|
|
877
|
+
}
|
|
878
|
+
return undefined;
|
|
879
|
+
};
|
|
853
880
|
const liveConfigs = new Map();
|
|
854
881
|
try {
|
|
855
882
|
for (const row of configEditor?.configuration() ?? []) {
|
|
856
|
-
const id = row.entry
|
|
883
|
+
const id = row.entry?.options?.id;
|
|
857
884
|
if (id !== undefined)
|
|
858
|
-
liveConfigs.set(id, row
|
|
885
|
+
liveConfigs.set(id, profileOf(row));
|
|
859
886
|
}
|
|
860
887
|
}
|
|
861
888
|
catch {
|
|
@@ -889,11 +916,15 @@ export class TokenQuotaService extends Service {
|
|
|
889
916
|
? record.baseURL
|
|
890
917
|
: undefined;
|
|
891
918
|
const kind = balanceKindOf(entry.provider, keyEnv, baseURL);
|
|
892
|
-
if (kind === undefined
|
|
919
|
+
if (kind === undefined)
|
|
893
920
|
continue;
|
|
921
|
+
// A provider may legitimately declare no apiKeyEnv (the adapter then
|
|
922
|
+
// resolves its family default); query that same reference rather than
|
|
923
|
+
// dropping the provider from the balance window.
|
|
924
|
+
const balanceKeyEnv = keyEnv ?? DEFAULT_BALANCE_KEY_ENV[kind];
|
|
894
925
|
found.set(entry.provider, {
|
|
895
926
|
provider: entry.provider,
|
|
896
|
-
keyEnv,
|
|
927
|
+
keyEnv: balanceKeyEnv,
|
|
897
928
|
baseURL: baseURL ?? (kind === 'deepseek' ? `https://${DEEPSEEK_BALANCE_HOST}` : `https://${TEAMOROUTER_HOST}`),
|
|
898
929
|
kind,
|
|
899
930
|
});
|
|
@@ -904,6 +935,14 @@ export class TokenQuotaService extends Service {
|
|
|
904
935
|
}
|
|
905
936
|
if (found.size === 0)
|
|
906
937
|
found.set('deepseek', fallback());
|
|
938
|
+
// One line per discovery pass, so a deployment can be checked from the
|
|
939
|
+
// terminal that runs `dsh web` instead of guessing from the panel.
|
|
940
|
+
try {
|
|
941
|
+
this.ctx.logger?.info(`token-quota: balance sources = ${[...found.values()].map(source => `${source.provider}(${source.kind})`).join(', ')}`);
|
|
942
|
+
}
|
|
943
|
+
catch {
|
|
944
|
+
// Logging is best-effort.
|
|
945
|
+
}
|
|
907
946
|
return found;
|
|
908
947
|
}
|
|
909
948
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jxgame2020/dsh-token-quota",
|
|
3
3
|
"description": "Daily per-model token quota accounting, enforcement, and a floating quota panel for the DeepSeek Harness — a fully self-contained plugin (no core-Harness wiring, no generated RPC contract)",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.54",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -39,6 +39,9 @@
|
|
|
39
39
|
"@deepseek-ai/dsh-api-remotes"
|
|
40
40
|
],
|
|
41
41
|
"platform": "web"
|
|
42
|
+
},
|
|
43
|
+
"bundle": {
|
|
44
|
+
"patch": "./cordis.patch.yml"
|
|
42
45
|
}
|
|
43
46
|
},
|
|
44
47
|
"scripts": {
|
|
@@ -50,6 +53,7 @@
|
|
|
50
53
|
"lib/index.js",
|
|
51
54
|
"lib/invariant.js",
|
|
52
55
|
"lib/client.js",
|
|
56
|
+
"cordis.patch.yml",
|
|
53
57
|
"lib/types/**/*.js",
|
|
54
58
|
"lib/types/**/*.d.ts"
|
|
55
59
|
],
|