dsh-magpie-connect 0.7.2 → 0.7.3
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/dsh.plugin.json +1 -1
- package/lib/client.js +26 -24
- package/lib/types/client/trace-format.d.ts +27 -11
- package/package.json +1 -1
package/dsh.plugin.json
CHANGED
package/lib/client.js
CHANGED
|
@@ -157,12 +157,10 @@ var EN = {
|
|
|
157
157
|
"trace.quotaReset": "reset in {d}",
|
|
158
158
|
"trace.candidate.used": "{n}% used",
|
|
159
159
|
"trace.candidate.amount": "{amount} / {limit} {unit}",
|
|
160
|
+
"trace.candidate.amountPct": "{amount} / {limit} {unit} \xB7 {n}% used",
|
|
160
161
|
"trace.unit.credits": "credits",
|
|
161
|
-
"trace.unit.credits.total": "total credits",
|
|
162
162
|
"trace.unit.tokens": "tokens",
|
|
163
|
-
"trace.unit.tokens.total": "total tokens",
|
|
164
163
|
"trace.unit.requests": "requests",
|
|
165
|
-
"trace.unit.requests.total": "total requests",
|
|
166
164
|
"trace.webTraceMissing": "Save the Magpie Web Key for full routing-group detail.",
|
|
167
165
|
"trace.webTraceUnauthorized": "Magpie Web Key was refused; the simplified routing view remains.",
|
|
168
166
|
"trace.webTraceUnavailable": "Full routing-group detail is unavailable; showing the simplified view.",
|
|
@@ -301,16 +299,14 @@ var ZH = {
|
|
|
301
299
|
"trace.reason.windowSize": "\u8D85\u51FA\u5176 {n}K \u4E0A\u4E0B\u6587",
|
|
302
300
|
"trace.reason.noURL": "\u7F3A\u5C11 API \u5730\u5740",
|
|
303
301
|
"trace.reason.other": "\u6682\u4E0D\u53EF\u7528",
|
|
304
|
-
"trace.restUntil": "{d}
|
|
305
|
-
"trace.quotaReset": "{d}
|
|
302
|
+
"trace.restUntil": "{d}\u540E\u6062\u590D",
|
|
303
|
+
"trace.quotaReset": "{d}\u540E\u91CD\u7F6E",
|
|
306
304
|
"trace.candidate.used": "\u5DF2\u7528 {n}%",
|
|
307
305
|
"trace.candidate.amount": "{amount} / {limit} {unit}",
|
|
306
|
+
"trace.candidate.amountPct": "{amount} / {limit} {unit} \xB7 \u5DF2\u7528 {n}%",
|
|
308
307
|
"trace.unit.credits": "\u79EF\u5206",
|
|
309
|
-
"trace.unit.credits.total": "\u603B\u79EF\u5206",
|
|
310
308
|
"trace.unit.tokens": "tokens",
|
|
311
|
-
"trace.unit.tokens.total": "\u603B tokens",
|
|
312
309
|
"trace.unit.requests": "\u6B21",
|
|
313
|
-
"trace.unit.requests.total": "\u603B\u6B21\u6570",
|
|
314
310
|
"trace.webTraceMissing": "\u4FDD\u5B58 Magpie Web Key \u540E\u53EF\u663E\u793A\u5B8C\u6574\u8DEF\u7531\u7EC4\u8BE6\u60C5\u3002",
|
|
315
311
|
"trace.webTraceUnauthorized": "Magpie Web Key \u88AB\u62D2\u7EDD\uFF1B\u5F53\u524D\u663E\u793A\u7B80\u5316\u8DEF\u7531\u89C6\u56FE\u3002",
|
|
316
312
|
"trace.webTraceUnavailable": "\u5B8C\u6574\u8DEF\u7531\u7EC4\u8BE6\u60C5\u6682\u4E0D\u53EF\u7528\uFF1B\u5F53\u524D\u663E\u793A\u7B80\u5316\u89C6\u56FE\u3002",
|
|
@@ -781,7 +777,7 @@ function shouldRetryPending(snapshot2, attempts, limit = PENDING_RETRY_LIMIT) {
|
|
|
781
777
|
|
|
782
778
|
// src/client/page.tsx
|
|
783
779
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
784
|
-
var PLUGIN_VERSION = "0.7.
|
|
780
|
+
var PLUGIN_VERSION = "0.7.3";
|
|
785
781
|
var REPO_URL = "https://github.com/bitxeno/dsh-magpie-connect";
|
|
786
782
|
var css2 = {
|
|
787
783
|
section: { display: "flex", flexDirection: "column", gap: 16, maxWidth: 780, paddingBottom: 32 },
|
|
@@ -1281,16 +1277,24 @@ function resetParts(resetsAt, now = Date.now()) {
|
|
|
1281
1277
|
if (resetsAt === void 0) return void 0;
|
|
1282
1278
|
const at = Date.parse(resetsAt);
|
|
1283
1279
|
if (!Number.isFinite(at) || at <= now) return void 0;
|
|
1284
|
-
const
|
|
1285
|
-
const minutes = Math.ceil(ms / 6e4);
|
|
1280
|
+
const minutes = Math.max(1, Math.round((at - now) / 6e4));
|
|
1286
1281
|
if (minutes < 60) return { n: minutes, unit: "m" };
|
|
1287
|
-
const hours = Math.
|
|
1282
|
+
const hours = Math.round(minutes / 60);
|
|
1288
1283
|
if (hours < 48) return { n: hours, unit: "h" };
|
|
1289
|
-
return { n: Math.
|
|
1284
|
+
return { n: Math.round(hours / 24), unit: "d" };
|
|
1290
1285
|
}
|
|
1291
|
-
function
|
|
1292
|
-
|
|
1293
|
-
|
|
1286
|
+
function roundAmount(value) {
|
|
1287
|
+
return value !== void 0 && Number.isFinite(value) ? Math.round(value * 100) / 100 : void 0;
|
|
1288
|
+
}
|
|
1289
|
+
function usageText(facts) {
|
|
1290
|
+
const amount = roundAmount(facts.amount);
|
|
1291
|
+
const limit = roundAmount(facts.limit);
|
|
1292
|
+
const usedPct = facts.usedPct;
|
|
1293
|
+
const unit = facts.unit ?? "";
|
|
1294
|
+
if (amount !== void 0 && limit !== void 0) {
|
|
1295
|
+
return usedPct !== void 0 ? { template: "trace.candidate.amountPct", params: { amount, limit, unit, n: usedPct } } : { template: "trace.candidate.amount", params: { amount, limit, unit } };
|
|
1296
|
+
}
|
|
1297
|
+
return usedPct !== void 0 ? { template: "trace.candidate.used", params: { n: usedPct } } : void 0;
|
|
1294
1298
|
}
|
|
1295
1299
|
function maskUser(user) {
|
|
1296
1300
|
if (user === void 0) return void 0;
|
|
@@ -1732,9 +1736,7 @@ var candidateDetailStyle = {
|
|
|
1732
1736
|
fontSize: "11px",
|
|
1733
1737
|
lineHeight: "16px",
|
|
1734
1738
|
color: "var(--dsw-alias-label-tertiary, #8a94a6)",
|
|
1735
|
-
|
|
1736
|
-
textOverflow: "ellipsis",
|
|
1737
|
-
whiteSpace: "nowrap"
|
|
1739
|
+
overflowWrap: "break-word"
|
|
1738
1740
|
};
|
|
1739
1741
|
var candidateGaugeStyle = {
|
|
1740
1742
|
marginTop: "6px",
|
|
@@ -1942,12 +1944,12 @@ function candidateDetail(candidate) {
|
|
|
1942
1944
|
const resetText2 = renew2 !== void 0 ? text("trace.quotaReset", { d: formatDuration(renew2, "reset") }) : "";
|
|
1943
1945
|
return [reason, resetText2].filter(Boolean).join(" \xB7 ");
|
|
1944
1946
|
}
|
|
1945
|
-
const amount = candidate.amount
|
|
1946
|
-
const limit = candidate.limit
|
|
1947
|
-
const windowName = candidate.windowName;
|
|
1947
|
+
const amount = candidate.amount;
|
|
1948
|
+
const limit = candidate.limit;
|
|
1948
1949
|
const unitKey = candidate.unit !== void 0 && candidate.unit !== "" ? `trace.unit.${candidate.unit}` : "";
|
|
1949
|
-
const unit =
|
|
1950
|
-
const
|
|
1950
|
+
const unit = unitKey !== "" && text(unitKey) !== unitKey ? text(unitKey) : candidate.unit ?? "";
|
|
1951
|
+
const usage = usageText({ amount, limit, unit, usedPct: candidate.usedPct });
|
|
1952
|
+
const amountText = usage !== void 0 ? text(usage.template, usage.params).trim() : "";
|
|
1951
1953
|
const renew = candidate.renews?.[0] !== void 0 ? resetParts(candidate.renews[0]) : void 0;
|
|
1952
1954
|
const resetText = renew !== void 0 ? text("trace.quotaReset", { d: formatDuration(renew, "reset") }) : "";
|
|
1953
1955
|
return [amountText, resetText].filter(Boolean).join(" \xB7 ");
|
|
@@ -24,10 +24,14 @@ export declare function durationParts(ms: number | undefined): DurationParts | u
|
|
|
24
24
|
/** How long until a reset is worded: pieces a locale template fills in. */
|
|
25
25
|
export type ResetParts = DurationParts;
|
|
26
26
|
/**
|
|
27
|
-
* Compress the wait until a quota window resets
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
27
|
+
* Compress the wait until a quota window resets, word for word the way
|
|
28
|
+
* Magpie's own page does it (`untilText` in its app.js): round to the
|
|
29
|
+
* nearest unit, minutes below an hour, hours below two days, days past
|
|
30
|
+
* that. The popover sits beside that page, so both must say the same
|
|
31
|
+
* number — rounding each step up here instead made a reset 12 days and 8
|
|
32
|
+
* hours away read "13 天" against Magpie's "12 天". Sub-minute waits read
|
|
33
|
+
* as one minute rather than zero, since the popover refreshes more slowly
|
|
34
|
+
* than that.
|
|
31
35
|
* @param resetsAt - the reset instant (RFC 3339) or undefined.
|
|
32
36
|
* @param now - the reference instant (epoch ms); defaults to the caller's clock.
|
|
33
37
|
* @returns the countdown, or `undefined` when the date is absent or past.
|
|
@@ -58,15 +62,27 @@ export declare function requestTone(row: TraceRequestRow): RequestTone;
|
|
|
58
62
|
export declare function requestModelLabel(row: TraceRequestRow): string;
|
|
59
63
|
/** Where a request was served, as one "provider · account" string ('' when unknown). */
|
|
60
64
|
export declare function requestPlaceLabel(row: TraceRequestRow): string;
|
|
65
|
+
/** Which locale template words a candidate's usage. */
|
|
66
|
+
export type UsageTemplate = 'trace.candidate.amountPct' | 'trace.candidate.amount' | 'trace.candidate.used';
|
|
67
|
+
/** One candidate's usage line: the template to fill and its params. */
|
|
68
|
+
export interface UsageText {
|
|
69
|
+
readonly template: UsageTemplate;
|
|
70
|
+
readonly params: Record<string, string | number>;
|
|
71
|
+
}
|
|
61
72
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* @param
|
|
67
|
-
* @returns
|
|
73
|
+
* Word one candidate's usage. A counted window (an amount/limit pair) says
|
|
74
|
+
* its figures *and* its share — Magpie's own page leads with the percent,
|
|
75
|
+
* and the pair alone made a credits account the only row in the popover
|
|
76
|
+
* without one. A window that reports only a share says just that.
|
|
77
|
+
* @param facts - the candidate's counters; `unit` already localized.
|
|
78
|
+
* @returns the template and params, or `undefined` when there is nothing to say.
|
|
68
79
|
*/
|
|
69
|
-
export declare function
|
|
80
|
+
export declare function usageText(facts: {
|
|
81
|
+
readonly amount?: number;
|
|
82
|
+
readonly limit?: number;
|
|
83
|
+
readonly unit?: string;
|
|
84
|
+
readonly usedPct?: number;
|
|
85
|
+
}): UsageText | undefined;
|
|
70
86
|
/** The header line's compressed counts, locale-ready. */
|
|
71
87
|
export interface TotalsParts {
|
|
72
88
|
readonly requests: number;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-magpie-connect",
|
|
3
3
|
"description": "Magpie gateway models for DeepSeek Harness (DSH): native dsh-llm adapter plugin with image + responses + thinking levels.",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|