dsh-any-deepseek 0.0.27 → 0.0.29
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 +181 -33
- package/lib/http.d.ts +16 -0
- package/lib/index.js +35 -31
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -8,6 +8,31 @@ window.__ModuleLoader__.load({
|
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
//#region src/client/panel-api.ts
|
|
10
10
|
/**
|
|
11
|
+
* The label to show for the channel that is serving requests right now.
|
|
12
|
+
*
|
|
13
|
+
* 🔴 Owner request 2026-11-03: the sidebar should name the live provider so it does not require
|
|
14
|
+
* opening Settings. Owner constraint the same day: 「左下角空间小,字少点,表意明确即可」 — the seat is
|
|
15
|
+
* 256px wide and already carries a usage figure, so this returns the SHORTEST true sentence:
|
|
16
|
+
* just the channel's own label, with no 「当前供应商:」 prefix on every line.
|
|
17
|
+
*
|
|
18
|
+
* Three states, kept distinct for the same reason the balance row does it:
|
|
19
|
+
* · a label when a channel is selected and found;
|
|
20
|
+
* · `undefined` when nothing is selected — the caller renders nothing, because "no provider" is
|
|
21
|
+
* already visible as the model picker being unset and a red line here would be noise;
|
|
22
|
+
* · `未找到` when `current` names a channel that no longer exists. That one IS worth a word: the
|
|
23
|
+
* router will fall back, so requests still work, but the user's selection is pointing at
|
|
24
|
+
* something gone and only they can fix it.
|
|
25
|
+
* @param response - the `/channels` body, or undefined before it loads.
|
|
26
|
+
* @returns the short label, or undefined when there is nothing to say.
|
|
27
|
+
*/
|
|
28
|
+
function currentProviderLabel(response) {
|
|
29
|
+
if (response === void 0) return void 0;
|
|
30
|
+
const id = response.current;
|
|
31
|
+
if (id === void 0 || id === "") return void 0;
|
|
32
|
+
const channel = response.channels.find((candidate) => candidate.id === id);
|
|
33
|
+
return channel === void 0 ? "未找到" : channel.label;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
11
36
|
* Load per-channel balances.
|
|
12
37
|
*
|
|
13
38
|
* Degrades to an empty list rather than throwing: the panel must still render the channel table
|
|
@@ -23,6 +48,45 @@ window.__ModuleLoader__.load({
|
|
|
23
48
|
}
|
|
24
49
|
}
|
|
25
50
|
/**
|
|
51
|
+
* How long until an instant, in words a person reads at a glance.
|
|
52
|
+
*
|
|
53
|
+
* 🔴 **Owner request 2026-11-03**: 「对于有时间限的渠道,opencode go 和 ollama 显示 还有多久」.
|
|
54
|
+
* Both channels meter against a clock, but they expose it differently: OpenCode Go attaches
|
|
55
|
+
* `resetsAt` to each of its three windows, Ollama puts the cycle end inside `period.until`. Until
|
|
56
|
+
* now the panel showed `rolling 95%` and `46.76 USD` — a percentage and a dollar figure that say
|
|
57
|
+
* nothing about WHEN the allowance comes back. The reset instant was already in the payload and
|
|
58
|
+
* already parsed into `resetsAt`; it was simply never rendered.
|
|
59
|
+
*
|
|
60
|
+
* ## The three distinctions this function refuses to collapse
|
|
61
|
+
*
|
|
62
|
+
* 1. **Past vs future.** A `resetsAt` in the past means the window has already rolled over and
|
|
63
|
+
* this reading is a snapshot from before the roll — the number on screen is stale, not zero.
|
|
64
|
+
* Saying 「已重置」 is honest; saying 「还有 0 分钟」 would claim a reset is imminent forever.
|
|
65
|
+
* 2. **Unknown vs absent.** An unparseable or missing instant is `undefined`, which the caller
|
|
66
|
+
* renders as nothing. It must not become 「还有 0 分钟」 — that is a reading nobody took.
|
|
67
|
+
* 3. **Granularity by magnitude.** `还有 3 天` is useful; `还有 2,847 分钟` is arithmetic homework.
|
|
68
|
+
* Days for long horizons, hours for a day, minutes under an hour — the unit follows what the
|
|
69
|
+
* reader would actually do with the answer.
|
|
70
|
+
*
|
|
71
|
+
* @param resetsAt - the instant the allowance returns, as the provider spelled it.
|
|
72
|
+
* @param now - clock, injectable for tests.
|
|
73
|
+
* @returns e.g. `还有 3 天`, `还有 4 小时`, `还有 12 分钟`, `已重置`; or `undefined` when the
|
|
74
|
+
* instant is absent or unparseable.
|
|
75
|
+
*/
|
|
76
|
+
function formatTimeUntil(resetsAt, now = /* @__PURE__ */ new Date()) {
|
|
77
|
+
if (resetsAt === void 0) return void 0;
|
|
78
|
+
const target = Date.parse(resetsAt);
|
|
79
|
+
if (!Number.isFinite(target)) return void 0;
|
|
80
|
+
const deltaMs = target - now.getTime();
|
|
81
|
+
if (deltaMs <= 0) return "已重置";
|
|
82
|
+
const minutes = Math.floor(deltaMs / 6e4);
|
|
83
|
+
if (minutes < 1) return "不到 1 分钟";
|
|
84
|
+
if (minutes < 60) return `还有 ${minutes} 分钟`;
|
|
85
|
+
const hours = Math.floor(minutes / 60);
|
|
86
|
+
if (hours < 24) return `还有 ${hours} 小时`;
|
|
87
|
+
return `还有 ${Math.floor(hours / 24)} 天`;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
26
90
|
* Render one balance row as the text a person reads.
|
|
27
91
|
*
|
|
28
92
|
* Deliberately total: every status produces words, never an empty string. A blank cell beside a
|
|
@@ -34,9 +98,10 @@ window.__ModuleLoader__.load({
|
|
|
34
98
|
* very figure this status exists to avoid inventing (owner directive 2026-10-23: 「不支持查余额的,
|
|
35
99
|
* 改成直接测通,通则说明余额还是有的,没用完」).
|
|
36
100
|
* @param row - one row from `/balance`.
|
|
101
|
+
* @param now - clock, injectable so the time-remaining text can be pinned in tests.
|
|
37
102
|
* @returns a short human label.
|
|
38
103
|
*/
|
|
39
|
-
function formatBalance(row) {
|
|
104
|
+
function formatBalance(row, now = /* @__PURE__ */ new Date()) {
|
|
40
105
|
if (row.status === "alive") return `余额未尽(无余额接口,实测可用:${row.responded === void 0 ? `${Math.round(row.ms)}ms` : `${row.responded} · ${Math.round(row.ms)}ms`})`;
|
|
41
106
|
if (row.status !== "ok") {
|
|
42
107
|
if (row.status === "no-key") return "未配置密钥";
|
|
@@ -47,11 +112,39 @@ window.__ModuleLoader__.load({
|
|
|
47
112
|
const { amounts, windows, available } = row.reading;
|
|
48
113
|
const parts = [];
|
|
49
114
|
for (const amount of amounts) parts.push(`${amount.remaining.toFixed(2)} ${amount.currency}`);
|
|
50
|
-
for (const window of windows)
|
|
115
|
+
for (const window of windows) {
|
|
116
|
+
const until = formatTimeUntil(window.resetsAt, now);
|
|
117
|
+
const suffix = until === void 0 ? "" : `(${until})`;
|
|
118
|
+
parts.push(`${window.name} ${Math.round(window.remainingPercent)}%${suffix}`);
|
|
119
|
+
}
|
|
51
120
|
if (available === false) parts.push("(余额不足)");
|
|
52
|
-
if (
|
|
121
|
+
if (row.reading.note !== void 0 && row.reading.note !== "") parts.push(describeNote(row.reading.note, now));
|
|
122
|
+
if (parts.length === 0) return "无可读数值";
|
|
53
123
|
return parts.join(" · ");
|
|
54
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Turn a provider note into something with a readable time horizon.
|
|
127
|
+
*
|
|
128
|
+
* The only note this rewrites is Ollama's `period <from> → <until>` — the rest are already prose
|
|
129
|
+
* written for a human (「unlimited」 and friends) and pass through untouched.
|
|
130
|
+
*
|
|
131
|
+
* 🔴 Why rewrite rather than append: 「period 2026-10-19T13:07:35Z → 2026-11-19T13:07:35Z」 is two
|
|
132
|
+
* ISO timestamps. The reader wants "how long until it renews", not a diff to do in their head.
|
|
133
|
+
* The absolute dates stay, because a horizon without an anchor cannot be checked against a
|
|
134
|
+
* calendar.
|
|
135
|
+
* @param note - the reading's note, verbatim from the parser.
|
|
136
|
+
* @param now - clock, injectable for tests.
|
|
137
|
+
* @returns the note, with an added 「还有 N 天」 when it is a period statement.
|
|
138
|
+
*/
|
|
139
|
+
function describeNote(note, now = /* @__PURE__ */ new Date()) {
|
|
140
|
+
const period = /^period\s+(\S+)\s+→\s+(\S+)$/.exec(note);
|
|
141
|
+
if (period === null) return note;
|
|
142
|
+
const from = period[1] ?? "";
|
|
143
|
+
const until = period[2] ?? "";
|
|
144
|
+
const untilText = formatTimeUntil(until, now);
|
|
145
|
+
if (untilText === void 0) return `周期 ${from} → ${until}`;
|
|
146
|
+
return `周期至 ${until.slice(0, 10)}(${untilText})`;
|
|
147
|
+
}
|
|
55
148
|
const BASE = "/any-deepseek";
|
|
56
149
|
/**
|
|
57
150
|
* Load the channel list.
|
|
@@ -1209,7 +1302,7 @@ window.__ModuleLoader__.load({
|
|
|
1209
1302
|
}
|
|
1210
1303
|
//#endregion
|
|
1211
1304
|
//#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:
|
|
1305
|
+
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 /* 🔴 Two rows since 2026-11-03 (usage + current provider). This is the COLUMN; each line is a\n `.ad-usageRow`. Owner constraint the same day: 「左下角空间小」 — so it stacks vertically\n instead of growing sideways into the 256px footer row. */\n display: inline-flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 2px;\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: 16px;\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 the label ellipsis. Without it a flex item refuses to\n shrink below its content, so the label's `text-overflow` rule never fires and the badge\n 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/* One line of the badge. Both rows share this shape so their dots line up in a column. */\n.ad-usageRow {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n min-width: 0;\n max-width: 100%;\n}\n\n/* The provider name is the only thing on its line that may be clipped — see `.ad-usageNum`. */\n.ad-providerName {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* The provider dot is dimmer than the usage dot: a static fact, not a live reading. */\n.ad-providerDot {\n opacity: 0.3;\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
1306
|
if (typeof document !== "undefined" && document.querySelector("style[data-ad-css=\"UsageBadge\"]") === null) {
|
|
1214
1307
|
const tag = document.createElement("style");
|
|
1215
1308
|
tag.setAttribute("data-ad-css", "UsageBadge");
|
|
@@ -1261,8 +1354,33 @@ window.__ModuleLoader__.load({
|
|
|
1261
1354
|
* late, absent, or refused would otherwise lose the badge with no trace — the exact silent shape
|
|
1262
1355
|
* decision 22 was written to remove.
|
|
1263
1356
|
*/
|
|
1264
|
-
/**
|
|
1265
|
-
|
|
1357
|
+
/**
|
|
1358
|
+
* Refresh cadence: **five minutes**.
|
|
1359
|
+
*
|
|
1360
|
+
* 🔴 Owner set this on 2026-11-01 ("每5分钟刷新一次值"). It replaces the earlier one-minute value,
|
|
1361
|
+
* which was my own guess. The trade is stated rather than hidden: a figure can be up to five
|
|
1362
|
+
* minutes stale, and in exchange the badge stops being a meaningful load on a route that reads the
|
|
1363
|
+
* whole month's ledger files on every call.
|
|
1364
|
+
*
|
|
1365
|
+
* ⚠️ Why this is a named constant and not a literal at the call site: it is the ONE number that
|
|
1366
|
+
* decides how stale the screen is, and a reader asking "how current is this?" must be able to find
|
|
1367
|
+
* it without reading the component body. It is asserted in `tests/UsageBadge.test.ts` so that a
|
|
1368
|
+
* future edit cannot quietly change the cadence the owner asked for.
|
|
1369
|
+
*/
|
|
1370
|
+
const USAGE_BADGE_REFRESH_MS = 3e5;
|
|
1371
|
+
/**
|
|
1372
|
+
* The visible label, in words, so the number is not ambiguous.
|
|
1373
|
+
*
|
|
1374
|
+
* 🔴 Owner asked for this on 2026-11-01 ("显示的内容多几个字,注明是今日 token 消耗"): a bare
|
|
1375
|
+
* `1465.2M` beside an account row could be read as anything — balance, quota, spend, requests.
|
|
1376
|
+
* A figure whose meaning has to be guessed is worse than no figure, because it invites a wrong
|
|
1377
|
+
* conclusion at a glance.
|
|
1378
|
+
*
|
|
1379
|
+
* ⚠️ It says 消耗 (consumed) while the tooltip and the ledger say 计费输入 (billable input). Both
|
|
1380
|
+
* name the SAME quantity — see the module note: uncached + cache read + cache write. 消耗 is the
|
|
1381
|
+
* reader-facing word, 计费输入 is the accounting term; they are not two conventions.
|
|
1382
|
+
*/
|
|
1383
|
+
const USAGE_BADGE_LABEL = "今日 Token 消耗";
|
|
1266
1384
|
/**
|
|
1267
1385
|
* Extract today's billable input from a stats response.
|
|
1268
1386
|
*
|
|
@@ -1308,14 +1426,18 @@ window.__ModuleLoader__.load({
|
|
|
1308
1426
|
* @param props - slot runtime share and the injected loader.
|
|
1309
1427
|
* @returns the badge, or null while there is nothing honest to show.
|
|
1310
1428
|
*/
|
|
1311
|
-
function UsageBadge({ loadToday }) {
|
|
1429
|
+
function UsageBadge({ loadToday, loadChannels }) {
|
|
1312
1430
|
const [value, setValue] = (0, react.useState)(null);
|
|
1313
1431
|
const [failed, setFailed] = (0, react.useState)(false);
|
|
1314
1432
|
const [day, setDay] = (0, react.useState)(() => localDayKey());
|
|
1433
|
+
const [channels, setChannels] = (0, react.useState)(void 0);
|
|
1315
1434
|
const alive = (0, react.useRef)(true);
|
|
1316
|
-
/** One read. Failures land in `failed`, never in `value`. */
|
|
1435
|
+
/** One read of BOTH facts the seat shows. Failures land in `failed`, never in `value`. */
|
|
1317
1436
|
const read = (0, react.useCallback)(async () => {
|
|
1318
1437
|
const today = localDayKey();
|
|
1438
|
+
loadChannels().then((response) => {
|
|
1439
|
+
if (alive.current) setChannels(response);
|
|
1440
|
+
}).catch(() => void 0);
|
|
1319
1441
|
try {
|
|
1320
1442
|
const stats = await loadToday();
|
|
1321
1443
|
if (!alive.current) return;
|
|
@@ -1332,7 +1454,7 @@ window.__ModuleLoader__.load({
|
|
|
1332
1454
|
if (!alive.current) return;
|
|
1333
1455
|
setFailed(true);
|
|
1334
1456
|
}
|
|
1335
|
-
}, [loadToday]);
|
|
1457
|
+
}, [loadToday, loadChannels]);
|
|
1336
1458
|
(0, react.useEffect)(() => {
|
|
1337
1459
|
alive.current = true;
|
|
1338
1460
|
read();
|
|
@@ -1345,27 +1467,50 @@ window.__ModuleLoader__.load({
|
|
|
1345
1467
|
};
|
|
1346
1468
|
}, [read]);
|
|
1347
1469
|
const state = badgeState(value, failed);
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1470
|
+
/**
|
|
1471
|
+
* The provider line, or nothing.
|
|
1472
|
+
*
|
|
1473
|
+
* 🔴 Owner request 2026-11-03 (with the screenshot): show the current provider here so switching
|
|
1474
|
+
* relays does not require opening Settings. Owner constraint the same day: 「左下角空间小,字少点,
|
|
1475
|
+
* 表意明确即可」 — so this renders the channel's OWN LABEL and nothing else. No 「当前供应商:」
|
|
1476
|
+
* prefix: that phrase would eat 6 of the row's ~20 characters to say what the position already
|
|
1477
|
+
* says, and the row would then truncate the part the reader actually needs.
|
|
1478
|
+
*
|
|
1479
|
+
* Silence when nothing is selected — the model picker above already shows an unset state, and a
|
|
1480
|
+
* second red line about it would be noise. It is NOT silence for a dangling id: that one is a
|
|
1481
|
+
* selection pointing at a channel that no longer exists (see `currentProviderLabel`).
|
|
1482
|
+
*/
|
|
1483
|
+
const provider = currentProviderLabel(channels);
|
|
1484
|
+
if (state.kind === "hidden" && provider === void 0) return null;
|
|
1360
1485
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1361
1486
|
className: "ad-usageBadge",
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1487
|
+
children: [state.kind === "hidden" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1488
|
+
className: "ad-usageRow",
|
|
1489
|
+
title: state.kind === "unknown" ? "今天还没有读到用量(或用量接口暂时不可用)" : `${day} 计费输入 ${state.tokens.toLocaleString()} tokens(未命中 + 缓存读 + 缓存写)`,
|
|
1490
|
+
children: [
|
|
1491
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1492
|
+
className: "ad-usageDot",
|
|
1493
|
+
"aria-hidden": "true"
|
|
1494
|
+
}),
|
|
1495
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1496
|
+
className: "ad-usageLabel",
|
|
1497
|
+
children: USAGE_BADGE_LABEL
|
|
1498
|
+
}),
|
|
1499
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1500
|
+
className: "ad-usageNum",
|
|
1501
|
+
children: state.kind === "unknown" ? "—" : formatTokens(state.tokens)
|
|
1502
|
+
})
|
|
1503
|
+
]
|
|
1504
|
+
}), provider === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1505
|
+
className: "ad-usageRow ad-providerRow",
|
|
1506
|
+
title: "当前供应商(请求正在走的那个渠道)",
|
|
1507
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1508
|
+
className: "ad-usageDot ad-providerDot",
|
|
1509
|
+
"aria-hidden": "true"
|
|
1510
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1511
|
+
className: "ad-providerName",
|
|
1512
|
+
children: provider
|
|
1513
|
+
})]
|
|
1369
1514
|
})]
|
|
1370
1515
|
});
|
|
1371
1516
|
}
|
|
@@ -1403,11 +1548,14 @@ window.__ModuleLoader__.load({
|
|
|
1403
1548
|
name: "sidebar.footer.action",
|
|
1404
1549
|
id: "any-deepseek-usage",
|
|
1405
1550
|
order: 90,
|
|
1406
|
-
inject: () => ({
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1551
|
+
inject: () => ({
|
|
1552
|
+
loadToday: () => {
|
|
1553
|
+
const start = /* @__PURE__ */ new Date();
|
|
1554
|
+
start.setHours(0, 0, 0, 0);
|
|
1555
|
+
return fetchStats("day", start.toISOString());
|
|
1556
|
+
},
|
|
1557
|
+
loadChannels: () => fetchChannels()
|
|
1558
|
+
})
|
|
1411
1559
|
}, UsageBadge);
|
|
1412
1560
|
} catch (error) {
|
|
1413
1561
|
console.error("[dsh-any-deepseek] sidebar usage badge registration refused:", error);
|
package/lib/http.d.ts
CHANGED
|
@@ -36,6 +36,22 @@ export interface RouteDeps {
|
|
|
36
36
|
id: string;
|
|
37
37
|
name: string;
|
|
38
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* The channel id that currently serves requests.
|
|
41
|
+
*
|
|
42
|
+
* 🔴 Owner request 2026-11-03: the sidebar should show which provider is live, so the reader
|
|
43
|
+
* does not have to open Settings to find out. This is the ONE axis that answers it (`enabled`
|
|
44
|
+
* was removed on 2026-10-21 precisely because two axes could disagree), so it is passed here
|
|
45
|
+
* rather than reconstructed on the client from the settings document — the settings document is
|
|
46
|
+
* what was WRITTEN, this is what the router actually reads.
|
|
47
|
+
* @returns the configured id, or undefined when nothing is selected.
|
|
48
|
+
*
|
|
49
|
+
* ⚠️ Optional, and its absence is treated as "nothing selected" rather than as an error: the
|
|
50
|
+
* route must keep working for any caller that predates this field (including the existing test
|
|
51
|
+
* fixtures). A hard requirement here would turn a decorative addition into a way to break the
|
|
52
|
+
* whole channel list.
|
|
53
|
+
*/
|
|
54
|
+
current?: () => string | undefined;
|
|
39
55
|
/** Describe a credential reference (never its value). */
|
|
40
56
|
describeKey: (ref: string) => Promise<{
|
|
41
57
|
configured: boolean;
|
package/lib/index.js
CHANGED
|
@@ -2528,39 +2528,42 @@ function registerStatsRoutes(ctx, webServer, deps) {
|
|
|
2528
2528
|
kind: "exact",
|
|
2529
2529
|
path: `${ROUTE_PREFIX}/channels`,
|
|
2530
2530
|
handler: async (_req, res) => {
|
|
2531
|
+
const rows = await Promise.all(deps.channels().map(async (channel) => {
|
|
2532
|
+
/**
|
|
2533
|
+
* 🔴 The key is a property of the CHANNEL now, so "is one configured?" is answered
|
|
2534
|
+
* without consulting any credential store. A legacy reference still asks the harness,
|
|
2535
|
+
* and that answer is the only thing the panel ever learns about a reference: whether
|
|
2536
|
+
* it exists.
|
|
2537
|
+
*/
|
|
2538
|
+
const key = channel.credential.kind === "literal" ? {
|
|
2539
|
+
configured: channel.credential.value !== "",
|
|
2540
|
+
source: "channel"
|
|
2541
|
+
} : channel.credential.kind === "reference" ? await deps.describeKey(channel.credential.ref) : {
|
|
2542
|
+
configured: false,
|
|
2543
|
+
source: void 0
|
|
2544
|
+
};
|
|
2545
|
+
return {
|
|
2546
|
+
id: channel.id,
|
|
2547
|
+
label: channel.label,
|
|
2548
|
+
model: channel.model,
|
|
2549
|
+
api: channel.api,
|
|
2550
|
+
baseURL: channel.baseURL,
|
|
2551
|
+
contextWindow: channel.contextWindow,
|
|
2552
|
+
maxTokens: channel.maxTokens,
|
|
2553
|
+
input: [...channel.input],
|
|
2554
|
+
warnings: [...channel.warnings],
|
|
2555
|
+
keyConfigured: key.configured,
|
|
2556
|
+
...key.source === void 0 ? {} : { keySource: key.source },
|
|
2557
|
+
keyKind: channel.credential.kind,
|
|
2558
|
+
...channel.credential.kind === "reference" ? { keyRef: channel.credential.ref } : {}
|
|
2559
|
+
};
|
|
2560
|
+
}));
|
|
2561
|
+
const active = deps.current?.();
|
|
2531
2562
|
json(res, 200, {
|
|
2532
|
-
channels:
|
|
2533
|
-
/**
|
|
2534
|
-
* 🔴 The key is a property of the CHANNEL now, so "is one configured?" is answered
|
|
2535
|
-
* without consulting any credential store. A legacy reference still asks the harness,
|
|
2536
|
-
* and that answer is the only thing the panel ever learns about a reference: whether
|
|
2537
|
-
* it exists.
|
|
2538
|
-
*/
|
|
2539
|
-
const key = channel.credential.kind === "literal" ? {
|
|
2540
|
-
configured: channel.credential.value !== "",
|
|
2541
|
-
source: "channel"
|
|
2542
|
-
} : channel.credential.kind === "reference" ? await deps.describeKey(channel.credential.ref) : {
|
|
2543
|
-
configured: false,
|
|
2544
|
-
source: void 0
|
|
2545
|
-
};
|
|
2546
|
-
return {
|
|
2547
|
-
id: channel.id,
|
|
2548
|
-
label: channel.label,
|
|
2549
|
-
model: channel.model,
|
|
2550
|
-
api: channel.api,
|
|
2551
|
-
baseURL: channel.baseURL,
|
|
2552
|
-
contextWindow: channel.contextWindow,
|
|
2553
|
-
maxTokens: channel.maxTokens,
|
|
2554
|
-
input: [...channel.input],
|
|
2555
|
-
warnings: [...channel.warnings],
|
|
2556
|
-
keyConfigured: key.configured,
|
|
2557
|
-
...key.source === void 0 ? {} : { keySource: key.source },
|
|
2558
|
-
keyKind: channel.credential.kind,
|
|
2559
|
-
...channel.credential.kind === "reference" ? { keyRef: channel.credential.ref } : {}
|
|
2560
|
-
};
|
|
2561
|
-
})),
|
|
2563
|
+
channels: rows,
|
|
2562
2564
|
presets: deps.listPresets(),
|
|
2563
|
-
model: deps.advertised()
|
|
2565
|
+
model: deps.advertised(),
|
|
2566
|
+
...active === void 0 ? {} : { current: active }
|
|
2564
2567
|
});
|
|
2565
2568
|
}
|
|
2566
2569
|
},
|
|
@@ -2860,6 +2863,7 @@ function apply(ctx, config) {
|
|
|
2860
2863
|
id: ADVERTISED_MODEL_ID,
|
|
2861
2864
|
name: ADVERTISED_MODEL_NAME
|
|
2862
2865
|
}),
|
|
2866
|
+
current,
|
|
2863
2867
|
describeKey: async (ref) => {
|
|
2864
2868
|
const seam = credentials();
|
|
2865
2869
|
if (seam?.describe === void 0) return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-any-deepseek",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
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": {
|