dsh-any-deepseek 0.0.28 → 0.0.30
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 +178 -45
- 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,63 @@ 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
|
-
|
|
121
|
+
/**
|
|
122
|
+
* The note — but only when it adds something the line does not already say.
|
|
123
|
+
*
|
|
124
|
+
* 🔴 **This guard was missing in the first cut of 0.0.29, and the live payload caught it.**
|
|
125
|
+
* Rendering the note unconditionally made OpenCode Go's line
|
|
126
|
+
* `rolling 93%(还有 2 小时) · weekly 50%(还有 5 天) · monthly 23%(还有 2 天) ·
|
|
127
|
+
* subscription usage windows; the credit balance is not readable with an API key`
|
|
128
|
+
* — three windows that already answer the question, followed by a sentence explaining a
|
|
129
|
+
* limitation the reader did not ask about. The panel has ONE line per channel.
|
|
130
|
+
*
|
|
131
|
+
* The rule: a note that only *explains why a field is absent* is redundant once that field's
|
|
132
|
+
* absence is already visible (no amounts shown ⇒ obviously no amount). A note that carries a
|
|
133
|
+
* FACT — Ollama's `period … → …` is the only source of its cycle end — must be rendered.
|
|
134
|
+
* `describeNote` reports which kind it is, so the decision lives in one place rather than as a
|
|
135
|
+
* string comparison here.
|
|
136
|
+
*/
|
|
137
|
+
if (row.reading.note !== void 0 && row.reading.note !== "") {
|
|
138
|
+
const described = describeNote(row.reading.note, now);
|
|
139
|
+
if (described !== void 0) parts.push(described);
|
|
140
|
+
else if (parts.length === 0) parts.push(row.reading.note);
|
|
141
|
+
}
|
|
142
|
+
if (parts.length === 0) return "无可读数值";
|
|
53
143
|
return parts.join(" · ");
|
|
54
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Turn a provider note into something worth a place on the one-line balance cell — or nothing.
|
|
147
|
+
*
|
|
148
|
+
* Only one note shape carries a FACT the line cannot otherwise show: Ollama's
|
|
149
|
+
* `period <from> → <until>`, which is the sole source of that channel's cycle end. It is rewritten
|
|
150
|
+
* to 「周期至 <date>(还有 N 天)」.
|
|
151
|
+
*
|
|
152
|
+
* 🔴 Everything else returns `undefined`, i.e. is DROPPED. That is the measured correction from the
|
|
153
|
+
* first cut of 0.0.29: OpenCode Go's note is `subscription usage windows; the credit balance is not
|
|
154
|
+
* readable with an API key`, which explains why a field is missing — a fact the reader can already
|
|
155
|
+
* see (no amount is rendered). Appending it turned a clean three-window line into a wall of text in
|
|
156
|
+
* a 256px-wide panel. ⚠️ It is NOT lost: the same string still travels in `/balance`, and the
|
|
157
|
+
* panel's own documentation covers it, so a reader who wants the explanation can still find it.
|
|
158
|
+
*
|
|
159
|
+
* @param note - the reading's note, verbatim from the parser.
|
|
160
|
+
* @param now - clock, injectable for tests.
|
|
161
|
+
* @returns the rewritable sentence, or `undefined` when the note adds nothing to the line.
|
|
162
|
+
*/
|
|
163
|
+
function describeNote(note, now = /* @__PURE__ */ new Date()) {
|
|
164
|
+
const period = /^period\s+(\S+)\s+→\s+(\S+)$/.exec(note);
|
|
165
|
+
if (period === null) return void 0;
|
|
166
|
+
const from = period[1] ?? "";
|
|
167
|
+
const until = period[2] ?? "";
|
|
168
|
+
const untilText = formatTimeUntil(until, now);
|
|
169
|
+
if (untilText === void 0) return `周期 ${from} → ${until}`;
|
|
170
|
+
return `周期至 ${until.slice(0, 10)}(${untilText})`;
|
|
171
|
+
}
|
|
55
172
|
const BASE = "/any-deepseek";
|
|
56
173
|
/**
|
|
57
174
|
* Load the channel list.
|
|
@@ -1209,7 +1326,7 @@ window.__ModuleLoader__.load({
|
|
|
1209
1326
|
}
|
|
1210
1327
|
//#endregion
|
|
1211
1328
|
//#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:
|
|
1329
|
+
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
1330
|
if (typeof document !== "undefined" && document.querySelector("style[data-ad-css=\"UsageBadge\"]") === null) {
|
|
1214
1331
|
const tag = document.createElement("style");
|
|
1215
1332
|
tag.setAttribute("data-ad-css", "UsageBadge");
|
|
@@ -1333,14 +1450,18 @@ window.__ModuleLoader__.load({
|
|
|
1333
1450
|
* @param props - slot runtime share and the injected loader.
|
|
1334
1451
|
* @returns the badge, or null while there is nothing honest to show.
|
|
1335
1452
|
*/
|
|
1336
|
-
function UsageBadge({ loadToday }) {
|
|
1453
|
+
function UsageBadge({ loadToday, loadChannels }) {
|
|
1337
1454
|
const [value, setValue] = (0, react.useState)(null);
|
|
1338
1455
|
const [failed, setFailed] = (0, react.useState)(false);
|
|
1339
1456
|
const [day, setDay] = (0, react.useState)(() => localDayKey());
|
|
1457
|
+
const [channels, setChannels] = (0, react.useState)(void 0);
|
|
1340
1458
|
const alive = (0, react.useRef)(true);
|
|
1341
|
-
/** One read. Failures land in `failed`, never in `value`. */
|
|
1459
|
+
/** One read of BOTH facts the seat shows. Failures land in `failed`, never in `value`. */
|
|
1342
1460
|
const read = (0, react.useCallback)(async () => {
|
|
1343
1461
|
const today = localDayKey();
|
|
1462
|
+
loadChannels().then((response) => {
|
|
1463
|
+
if (alive.current) setChannels(response);
|
|
1464
|
+
}).catch(() => void 0);
|
|
1344
1465
|
try {
|
|
1345
1466
|
const stats = await loadToday();
|
|
1346
1467
|
if (!alive.current) return;
|
|
@@ -1357,7 +1478,7 @@ window.__ModuleLoader__.load({
|
|
|
1357
1478
|
if (!alive.current) return;
|
|
1358
1479
|
setFailed(true);
|
|
1359
1480
|
}
|
|
1360
|
-
}, [loadToday]);
|
|
1481
|
+
}, [loadToday, loadChannels]);
|
|
1361
1482
|
(0, react.useEffect)(() => {
|
|
1362
1483
|
alive.current = true;
|
|
1363
1484
|
read();
|
|
@@ -1370,42 +1491,51 @@ window.__ModuleLoader__.load({
|
|
|
1370
1491
|
};
|
|
1371
1492
|
}, [read]);
|
|
1372
1493
|
const state = badgeState(value, failed);
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
children: "—"
|
|
1389
|
-
})
|
|
1390
|
-
]
|
|
1391
|
-
});
|
|
1494
|
+
/**
|
|
1495
|
+
* The provider line, or nothing.
|
|
1496
|
+
*
|
|
1497
|
+
* 🔴 Owner request 2026-11-03 (with the screenshot): show the current provider here so switching
|
|
1498
|
+
* relays does not require opening Settings. Owner constraint the same day: 「左下角空间小,字少点,
|
|
1499
|
+
* 表意明确即可」 — so this renders the channel's OWN LABEL and nothing else. No 「当前供应商:」
|
|
1500
|
+
* prefix: that phrase would eat 6 of the row's ~20 characters to say what the position already
|
|
1501
|
+
* says, and the row would then truncate the part the reader actually needs.
|
|
1502
|
+
*
|
|
1503
|
+
* Silence when nothing is selected — the model picker above already shows an unset state, and a
|
|
1504
|
+
* second red line about it would be noise. It is NOT silence for a dangling id: that one is a
|
|
1505
|
+
* selection pointing at a channel that no longer exists (see `currentProviderLabel`).
|
|
1506
|
+
*/
|
|
1507
|
+
const provider = currentProviderLabel(channels);
|
|
1508
|
+
if (state.kind === "hidden" && provider === void 0) return null;
|
|
1392
1509
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1393
1510
|
className: "ad-usageBadge",
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1511
|
+
children: [state.kind === "hidden" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1512
|
+
className: "ad-usageRow",
|
|
1513
|
+
title: state.kind === "unknown" ? "今天还没有读到用量(或用量接口暂时不可用)" : `${day} 计费输入 ${state.tokens.toLocaleString()} tokens(未命中 + 缓存读 + 缓存写)`,
|
|
1514
|
+
children: [
|
|
1515
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1516
|
+
className: "ad-usageDot",
|
|
1517
|
+
"aria-hidden": "true"
|
|
1518
|
+
}),
|
|
1519
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1520
|
+
className: "ad-usageLabel",
|
|
1521
|
+
children: USAGE_BADGE_LABEL
|
|
1522
|
+
}),
|
|
1523
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1524
|
+
className: "ad-usageNum",
|
|
1525
|
+
children: state.kind === "unknown" ? "—" : formatTokens(state.tokens)
|
|
1526
|
+
})
|
|
1527
|
+
]
|
|
1528
|
+
}), provider === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1529
|
+
className: "ad-usageRow ad-providerRow",
|
|
1530
|
+
title: "当前供应商(请求正在走的那个渠道)",
|
|
1531
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1532
|
+
className: "ad-usageDot ad-providerDot",
|
|
1398
1533
|
"aria-hidden": "true"
|
|
1399
|
-
}),
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1405
|
-
className: "ad-usageNum",
|
|
1406
|
-
children: formatTokens(state.tokens)
|
|
1407
|
-
})
|
|
1408
|
-
]
|
|
1534
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1535
|
+
className: "ad-providerName",
|
|
1536
|
+
children: provider
|
|
1537
|
+
})]
|
|
1538
|
+
})]
|
|
1409
1539
|
});
|
|
1410
1540
|
}
|
|
1411
1541
|
//#endregion
|
|
@@ -1442,11 +1572,14 @@ window.__ModuleLoader__.load({
|
|
|
1442
1572
|
name: "sidebar.footer.action",
|
|
1443
1573
|
id: "any-deepseek-usage",
|
|
1444
1574
|
order: 90,
|
|
1445
|
-
inject: () => ({
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1575
|
+
inject: () => ({
|
|
1576
|
+
loadToday: () => {
|
|
1577
|
+
const start = /* @__PURE__ */ new Date();
|
|
1578
|
+
start.setHours(0, 0, 0, 0);
|
|
1579
|
+
return fetchStats("day", start.toISOString());
|
|
1580
|
+
},
|
|
1581
|
+
loadChannels: () => fetchChannels()
|
|
1582
|
+
})
|
|
1450
1583
|
}, UsageBadge);
|
|
1451
1584
|
} catch (error) {
|
|
1452
1585
|
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.30",
|
|
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": {
|