dsh-any-deepseek 0.0.26 → 0.0.28
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/lib/client.js +73 -25
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -1209,7 +1209,7 @@ window.__ModuleLoader__.load({
|
|
|
1209
1209
|
}
|
|
1210
1210
|
//#endregion
|
|
1211
1211
|
//#region \0ad-css:src/client/UsageBadge
|
|
1212
|
-
const css = "/**\n * UsageBadge.css — the header badge's own styles.\n *\n * Kept in its own file, imported by the component, because the build inlines CSS imports into the\n * bundle (`--loader:.css=text`). The panel's stylesheet is not reused on purpose: the badge lives\n * in the host's header, not inside the panel, and a shared sheet would tie two unrelated surfaces\n * together so that touching one breaks the other.\n *\n * ## Sizing follows the host, not our taste\n *\n * The host's header leading area is `display:flex; align-items:center; gap:8px`\n * (`ConversationRoot.module.css`: `.headerLeading`). So this contributes one flex item and does not\n * set its own margins. Height is left to the line box: the header row is 30px tall\n * (`.titleRow{min-height:30px}`), so a 20px line-height sits inside it without stretching it.\n *\n * ## Colour comes from the host's tokens\n *\n * `--dsw-alias-*` are the host's own aliases, the same family its crumbs and captions use. Hard-coded\n * greys would look correct in one theme and vanish in the other; three of the panel's earlier colour\n * defects were exactly this.\n */\n\n.ad-usageBadge {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n /* No padding/background: this is an ornament
|
|
1212
|
+
const css = "/**\n * UsageBadge.css — the header badge's own styles.\n *\n * Kept in its own file, imported by the component, because the build inlines CSS imports into the\n * bundle (`--loader:.css=text`). The panel's stylesheet is not reused on purpose: the badge lives\n * in the host's header, not inside the panel, and a shared sheet would tie two unrelated surfaces\n * together so that touching one breaks the other.\n *\n * ## Sizing follows the host, not our taste\n *\n * The host's header leading area is `display:flex; align-items:center; gap:8px`\n * (`ConversationRoot.module.css`: `.headerLeading`). So this contributes one flex item and does not\n * set its own margins. Height is left to the line box: the header row is 30px tall\n * (`.titleRow{min-height:30px}`), so a 20px line-height sits inside it without stretching it.\n *\n * ## Colour comes from the host's tokens\n *\n * `--dsw-alias-*` are the host's own aliases, the same family its crumbs and captions use. Hard-coded\n * greys would look correct in one theme and vanish in the other; three of the panel's earlier colour\n * defects were exactly this.\n */\n\n.ad-usageBadge {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n /* No padding/background: this is an ornament, not a button. Giving it a hit area would invite\n clicks that the owner explicitly did not ask for. */\n padding: 0;\n background: none;\n border: none;\n color: var(--dsw-alias-label-tertiary);\n font-size: 12px;\n line-height: 20px;\n /* Tabular figures stop the number's width from jittering as it grows during a session, which\n would drag everything to its right back and forth. */\n font-variant-numeric: tabular-nums;\n white-space: nowrap;\n /* 🔴 `min-width:0` is what actually lets `.ad-usageLabel` ellipsis. Without it a flex item\n refuses to shrink below its content, so the label's `text-overflow` rule never fires and the\n badge instead overflows the 256px footer row. */\n min-width: 0;\n max-width: 100%;\n /* This is a display ornament; text selection would fight the surrounding row. */\n user-select: none;\n}\n\n/* The dot is the \"this is a live reading\" cue. It is `aria-hidden` in the markup because the\n number and the title already say everything the dot implies. */\n.ad-usageDot {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: currentColor;\n opacity: 0.55;\n flex: none;\n}\n\n.ad-usageNum {\n font-weight: 500;\n /* The figure must not be the thing that gets squeezed when the sidebar narrows: the label may\n elide, the number may not — a truncated number is a wrong number, a truncated label is still\n a readable label. */\n flex: none;\n}\n\n/**\n * The visible label (\"今日 Token 消耗\").\n *\n * 🔴 Owner asked for it on 2026-11-01 so the figure cannot be misread as balance or quota.\n *\n * ⚠️ **It is allowed to shrink and elide, the number is not.** The seat is the sidebar footer —\n * 256px wide with the account row in it — so a long label plus a long figure can genuinely run out\n * of room. Clipping the LABEL degrades honestly (the dot + tooltip still say what it is); clipping\n * the NUMBER would show a figure that is not the figure.\n */\n.ad-usageLabel {\n font-weight: 400;\n opacity: 0.85;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* An unreadable figure is dimmed rather than hidden: the seat stays occupied so the footer does\n not reflow when the route comes back. */\n.ad-usageBadge[title^=\"今天还没有读到\"] {\n opacity: 0.6;\n}\n";
|
|
1213
1213
|
if (typeof document !== "undefined" && document.querySelector("style[data-ad-css=\"UsageBadge\"]") === null) {
|
|
1214
1214
|
const tag = document.createElement("style");
|
|
1215
1215
|
tag.setAttribute("data-ad-css", "UsageBadge");
|
|
@@ -1261,8 +1261,33 @@ window.__ModuleLoader__.load({
|
|
|
1261
1261
|
* late, absent, or refused would otherwise lose the badge with no trace — the exact silent shape
|
|
1262
1262
|
* decision 22 was written to remove.
|
|
1263
1263
|
*/
|
|
1264
|
-
/**
|
|
1265
|
-
|
|
1264
|
+
/**
|
|
1265
|
+
* Refresh cadence: **five minutes**.
|
|
1266
|
+
*
|
|
1267
|
+
* 🔴 Owner set this on 2026-11-01 ("每5分钟刷新一次值"). It replaces the earlier one-minute value,
|
|
1268
|
+
* which was my own guess. The trade is stated rather than hidden: a figure can be up to five
|
|
1269
|
+
* minutes stale, and in exchange the badge stops being a meaningful load on a route that reads the
|
|
1270
|
+
* whole month's ledger files on every call.
|
|
1271
|
+
*
|
|
1272
|
+
* ⚠️ Why this is a named constant and not a literal at the call site: it is the ONE number that
|
|
1273
|
+
* decides how stale the screen is, and a reader asking "how current is this?" must be able to find
|
|
1274
|
+
* it without reading the component body. It is asserted in `tests/UsageBadge.test.ts` so that a
|
|
1275
|
+
* future edit cannot quietly change the cadence the owner asked for.
|
|
1276
|
+
*/
|
|
1277
|
+
const USAGE_BADGE_REFRESH_MS = 3e5;
|
|
1278
|
+
/**
|
|
1279
|
+
* The visible label, in words, so the number is not ambiguous.
|
|
1280
|
+
*
|
|
1281
|
+
* 🔴 Owner asked for this on 2026-11-01 ("显示的内容多几个字,注明是今日 token 消耗"): a bare
|
|
1282
|
+
* `1465.2M` beside an account row could be read as anything — balance, quota, spend, requests.
|
|
1283
|
+
* A figure whose meaning has to be guessed is worse than no figure, because it invites a wrong
|
|
1284
|
+
* conclusion at a glance.
|
|
1285
|
+
*
|
|
1286
|
+
* ⚠️ It says 消耗 (consumed) while the tooltip and the ledger say 计费输入 (billable input). Both
|
|
1287
|
+
* name the SAME quantity — see the module note: uncached + cache read + cache write. 消耗 is the
|
|
1288
|
+
* reader-facing word, 计费输入 is the accounting term; they are not two conventions.
|
|
1289
|
+
*/
|
|
1290
|
+
const USAGE_BADGE_LABEL = "今日 Token 消耗";
|
|
1266
1291
|
/**
|
|
1267
1292
|
* Extract today's billable input from a stats response.
|
|
1268
1293
|
*
|
|
@@ -1349,24 +1374,38 @@ window.__ModuleLoader__.load({
|
|
|
1349
1374
|
if (state.kind === "unknown") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1350
1375
|
className: "ad-usageBadge",
|
|
1351
1376
|
title: "今天还没有读到用量(或用量接口暂时不可用)",
|
|
1352
|
-
children: [
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1377
|
+
children: [
|
|
1378
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1379
|
+
className: "ad-usageDot",
|
|
1380
|
+
"aria-hidden": "true"
|
|
1381
|
+
}),
|
|
1382
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1383
|
+
className: "ad-usageLabel",
|
|
1384
|
+
children: USAGE_BADGE_LABEL
|
|
1385
|
+
}),
|
|
1386
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1387
|
+
className: "ad-usageNum",
|
|
1388
|
+
children: "—"
|
|
1389
|
+
})
|
|
1390
|
+
]
|
|
1359
1391
|
});
|
|
1360
1392
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1361
1393
|
className: "ad-usageBadge",
|
|
1362
1394
|
title: `${day} 计费输入 ${state.tokens.toLocaleString()} tokens(未命中 + 缓存读 + 缓存写)`,
|
|
1363
|
-
children: [
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1395
|
+
children: [
|
|
1396
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1397
|
+
className: "ad-usageDot",
|
|
1398
|
+
"aria-hidden": "true"
|
|
1399
|
+
}),
|
|
1400
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1401
|
+
className: "ad-usageLabel",
|
|
1402
|
+
children: USAGE_BADGE_LABEL
|
|
1403
|
+
}),
|
|
1404
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1405
|
+
className: "ad-usageNum",
|
|
1406
|
+
children: formatTokens(state.tokens)
|
|
1407
|
+
})
|
|
1408
|
+
]
|
|
1370
1409
|
});
|
|
1371
1410
|
}
|
|
1372
1411
|
//#endregion
|
|
@@ -1397,14 +1436,23 @@ window.__ModuleLoader__.load({
|
|
|
1397
1436
|
const inject = ["slots"];
|
|
1398
1437
|
function apply(ctx) {
|
|
1399
1438
|
ctx.inject(["slots"], (scope) => {
|
|
1400
|
-
scope.effect(() => scope.slots.inject("
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1439
|
+
scope.effect(() => scope.slots.inject("sidebar.footer.action", () => {
|
|
1440
|
+
try {
|
|
1441
|
+
return scope.slots.register({
|
|
1442
|
+
name: "sidebar.footer.action",
|
|
1443
|
+
id: "any-deepseek-usage",
|
|
1444
|
+
order: 90,
|
|
1445
|
+
inject: () => ({ loadToday: () => {
|
|
1446
|
+
const start = /* @__PURE__ */ new Date();
|
|
1447
|
+
start.setHours(0, 0, 0, 0);
|
|
1448
|
+
return fetchStats("day", start.toISOString());
|
|
1449
|
+
} })
|
|
1450
|
+
}, UsageBadge);
|
|
1451
|
+
} catch (error) {
|
|
1452
|
+
console.error("[dsh-any-deepseek] sidebar usage badge registration refused:", error);
|
|
1453
|
+
throw error;
|
|
1454
|
+
}
|
|
1455
|
+
}), "any-deepseek sidebar usage badge");
|
|
1408
1456
|
});
|
|
1409
1457
|
ctx.inject(["slots", "configForms"], (scope) => {
|
|
1410
1458
|
const form = scope.configForms.get(SETTINGS_NS);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-any-deepseek",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"description": "One DeepSeek V4.1 Flash provider for DeepSeek Harness: paste a key per channel, switch channels manually, token usage booked per real upstream.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|