dsh-any-deepseek 0.0.35 → 0.0.37
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 +95 -10
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -225,6 +225,29 @@ window.__ModuleLoader__.load({
|
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
/**
|
|
228
|
+
* Load the channel list, but let a FAILURE be a failure.
|
|
229
|
+
*
|
|
230
|
+
* 🔴 Why this exists next to {@link fetchChannels} (2026-11-18): that one answers a dead route with
|
|
231
|
+
* an empty list, which is the right shape for the PANEL — an empty table is a truthful rendering of
|
|
232
|
+
* a deployment whose HTTP surface did not come up, and the user is looking right at it.
|
|
233
|
+
*
|
|
234
|
+
* For the sidebar's provider line it is the wrong shape. An empty response has no `current`, so
|
|
235
|
+
* `currentProviderLabel` returns `undefined` and the line DISAPPEARS. At the old 5-minute cadence
|
|
236
|
+
* that was a rare blink; the line now polls every 15 seconds, so silently accepting "no current"
|
|
237
|
+
* would turn one transient failure into the line vanishing ~5760 times a day — a 20× increase in
|
|
238
|
+
* exactly the defect this release is fixing (a line that misdescribes the live supplier).
|
|
239
|
+
*
|
|
240
|
+
* ⇒ Same route, opposite contract: this one rejects, so the caller can KEEP the last known name
|
|
241
|
+
* instead of replacing a true fact with silence.
|
|
242
|
+
* @returns the response, with `current` guaranteed present in the JSON shape we validate.
|
|
243
|
+
* @throws when the route is unreachable, non-200, or answers something that is not a channel list.
|
|
244
|
+
*/
|
|
245
|
+
async function fetchChannelsStrict() {
|
|
246
|
+
const response = await fetch(`${BASE}/channels`, { headers: { accept: "application/json" } });
|
|
247
|
+
if (!response.ok) throw new Error(`/channels answered ${response.status}`);
|
|
248
|
+
return await response.json();
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
228
251
|
* Load aggregates.
|
|
229
252
|
* @param group - `channel` for the per-relay table, `day` for the timeline.
|
|
230
253
|
* @param from - inclusive ISO lower bound.
|
|
@@ -1573,6 +1596,26 @@ window.__ModuleLoader__.load({
|
|
|
1573
1596
|
*/
|
|
1574
1597
|
const USAGE_BADGE_REFRESH_MS = 3e5;
|
|
1575
1598
|
/**
|
|
1599
|
+
* Refresh cadence for the PROVIDER line: **fifteen seconds**.
|
|
1600
|
+
*
|
|
1601
|
+
* 🔴 Owner report (2026-11-18): 「我设定不用供应组不生效了好像」 — the switch HAD taken effect (the ledger
|
|
1602
|
+
* proved it: within a minute the requests were all on the newly chosen channel), but this line still
|
|
1603
|
+
* named the old supplier, because it shares the 5-minute refresh above.
|
|
1604
|
+
*
|
|
1605
|
+
* ⚠️ **Why the two facts cannot share one cadence, stated as the reason the numbers differ**: the
|
|
1606
|
+
* usage figure is expensive — `/stats` reads the whole month's ledger files — and it is a DAILY
|
|
1607
|
+
* cumulative, so a five-minute lag changes it by a rounding error. The provider name is cheap — one
|
|
1608
|
+
* `/channels` read, no ledger — and it is instantaneous: the moment it is wrong, the reader believes
|
|
1609
|
+
* their selection did not apply, which is exactly what happened.
|
|
1610
|
+
*
|
|
1611
|
+
* ⇒ Two facts, two costs, two cadences. Coupling them was the bug; unifying them would only move it.
|
|
1612
|
+
*
|
|
1613
|
+
* 📌 **Residual staleness: up to 15 seconds, and it is real.** Not "instant": say what is true. A
|
|
1614
|
+
* focus / tab-switch also triggers an immediate read, which covers the common "I just changed it,
|
|
1615
|
+
* let me look at the corner" path.
|
|
1616
|
+
*/
|
|
1617
|
+
const PROVIDER_REFRESH_MS = 15e3;
|
|
1618
|
+
/**
|
|
1576
1619
|
* The visible label, in words, so the number is not ambiguous.
|
|
1577
1620
|
*
|
|
1578
1621
|
* 🔴 Owner asked for this on 2026-11-01 ("显示的内容多几个字,注明是今日 token 消耗"): a bare
|
|
@@ -1636,12 +1679,9 @@ window.__ModuleLoader__.load({
|
|
|
1636
1679
|
const [day, setDay] = (0, react.useState)(() => localDayKey());
|
|
1637
1680
|
const [channels, setChannels] = (0, react.useState)(void 0);
|
|
1638
1681
|
const alive = (0, react.useRef)(true);
|
|
1639
|
-
/** One read of
|
|
1682
|
+
/** One read of the usage figure. Failures land in `failed`, never in `value`. */
|
|
1640
1683
|
const read = (0, react.useCallback)(async () => {
|
|
1641
1684
|
const today = localDayKey();
|
|
1642
|
-
loadChannels().then((response) => {
|
|
1643
|
-
if (alive.current) setChannels(response);
|
|
1644
|
-
}).catch(() => void 0);
|
|
1645
1685
|
try {
|
|
1646
1686
|
const stats = await loadToday();
|
|
1647
1687
|
if (!alive.current) return;
|
|
@@ -1658,18 +1698,63 @@ window.__ModuleLoader__.load({
|
|
|
1658
1698
|
if (!alive.current) return;
|
|
1659
1699
|
setFailed(true);
|
|
1660
1700
|
}
|
|
1661
|
-
}, [loadToday
|
|
1701
|
+
}, [loadToday]);
|
|
1702
|
+
/**
|
|
1703
|
+
* One read of the PROVIDER line, on its own faster cadence.
|
|
1704
|
+
*
|
|
1705
|
+
* 🔴 Split from {@link read} on 2026-11-18 (owner report). The two facts used to share one timer
|
|
1706
|
+
* and that is exactly how the sidebar came to name a supplier that had already been switched away
|
|
1707
|
+
* from: the selection is instantaneous, the usage figure is a daily cumulative.
|
|
1708
|
+
*
|
|
1709
|
+
* ⚠️ **A failure keeps the last known name; it does not blank the line.** This is why the loader
|
|
1710
|
+
* is strict (`fetchChannelsStrict`) rather than the lenient `fetchChannels` the panel uses: that
|
|
1711
|
+
* one answers a dead route with an EMPTY list, which has no `current`, which renders as nothing.
|
|
1712
|
+
* At a 15-second cadence the lenient shape would make the line disappear thousands of times a day
|
|
1713
|
+
* — turning the fix into the same class of defect it was written to remove.
|
|
1714
|
+
*/
|
|
1715
|
+
const readProvider = (0, react.useCallback)(async () => {
|
|
1716
|
+
try {
|
|
1717
|
+
const response = await loadChannels();
|
|
1718
|
+
if (alive.current) setChannels(response);
|
|
1719
|
+
} catch {}
|
|
1720
|
+
}, [loadChannels]);
|
|
1662
1721
|
(0, react.useEffect)(() => {
|
|
1663
1722
|
alive.current = true;
|
|
1664
1723
|
read();
|
|
1665
|
-
|
|
1724
|
+
readProvider();
|
|
1725
|
+
const usageTimer = setInterval(() => {
|
|
1666
1726
|
read();
|
|
1667
1727
|
}, USAGE_BADGE_REFRESH_MS);
|
|
1728
|
+
const providerTimer = setInterval(() => {
|
|
1729
|
+
readProvider();
|
|
1730
|
+
}, PROVIDER_REFRESH_MS);
|
|
1668
1731
|
return () => {
|
|
1669
1732
|
alive.current = false;
|
|
1670
|
-
clearInterval(
|
|
1733
|
+
clearInterval(usageTimer);
|
|
1734
|
+
clearInterval(providerTimer);
|
|
1735
|
+
};
|
|
1736
|
+
}, [read, readProvider]);
|
|
1737
|
+
/**
|
|
1738
|
+
* Re-read the provider the moment the tab regains attention.
|
|
1739
|
+
*
|
|
1740
|
+
* 📌 This is the path that actually covers the owner's workflow: switch the channel in Settings,
|
|
1741
|
+
* come back to the conversation, glance at the corner. Waiting up to 15 seconds for a timer would
|
|
1742
|
+
* still look like "the switch did not take" — the same misreading, just shorter.
|
|
1743
|
+
*
|
|
1744
|
+
* ⚠️ It refreshes the PROVIDER only. Re-reading the ledger on every focus would turn a cosmetic
|
|
1745
|
+
* seat into a file-reading poll driven by the user's tab switching.
|
|
1746
|
+
*/
|
|
1747
|
+
(0, react.useEffect)(() => {
|
|
1748
|
+
const onVisible = () => {
|
|
1749
|
+
if (document.visibilityState === "visible") readProvider();
|
|
1750
|
+
};
|
|
1751
|
+
document.addEventListener("visibilitychange", onVisible);
|
|
1752
|
+
window.addEventListener("focus", onVisible);
|
|
1753
|
+
return () => {
|
|
1754
|
+
document.removeEventListener("visibilitychange", onVisible);
|
|
1755
|
+
window.removeEventListener("focus", onVisible);
|
|
1671
1756
|
};
|
|
1672
|
-
}, [
|
|
1757
|
+
}, [readProvider]);
|
|
1673
1758
|
const state = badgeState(value, failed);
|
|
1674
1759
|
/**
|
|
1675
1760
|
* The provider line, or nothing.
|
|
@@ -1707,7 +1792,7 @@ window.__ModuleLoader__.load({
|
|
|
1707
1792
|
]
|
|
1708
1793
|
}), provider === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1709
1794
|
className: "ad-usageRow ad-providerRow",
|
|
1710
|
-
title: "
|
|
1795
|
+
title: "当前供应商(请求正在走的那个渠道)。最多 15 秒延迟;切换渠道后回到本窗口会立刻重读。",
|
|
1711
1796
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1712
1797
|
className: "ad-usageDot ad-providerDot",
|
|
1713
1798
|
"aria-hidden": "true"
|
|
@@ -1758,7 +1843,7 @@ window.__ModuleLoader__.load({
|
|
|
1758
1843
|
start.setHours(0, 0, 0, 0);
|
|
1759
1844
|
return fetchStats("day", start.toISOString());
|
|
1760
1845
|
},
|
|
1761
|
-
loadChannels: () =>
|
|
1846
|
+
loadChannels: () => fetchChannelsStrict()
|
|
1762
1847
|
})
|
|
1763
1848
|
}, UsageBadge);
|
|
1764
1849
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-any-deepseek",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
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": {
|