@kenz1117/dsh-ui-usage-billing 1.8.8 → 1.8.10
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/README.en.md +7 -6
- package/README.md +17 -15
- package/lib/client.js +5 -5
- package/lib/index.js +241 -34
- package/lib/types/client/footer-lane.d.ts +65 -0
- package/lib/types/client/locales.d.ts +1 -1
- package/lib/types/client/usage-command.d.ts +10 -5
- package/lib/types/guard.d.ts +17 -0
- package/package.json +70 -65
package/lib/index.js
CHANGED
|
@@ -1022,6 +1022,18 @@ const BUILTIN_MODEL_CATALOG = [
|
|
|
1022
1022
|
output: 7
|
|
1023
1023
|
}
|
|
1024
1024
|
},
|
|
1025
|
+
{
|
|
1026
|
+
key: "glm-5.3-flashx-legal",
|
|
1027
|
+
name: "GLM-5.3-FlashX-Legal",
|
|
1028
|
+
provider: "智谱 AI",
|
|
1029
|
+
colorVar: "dsw-static-blue-300",
|
|
1030
|
+
price: {
|
|
1031
|
+
currency: "CNY",
|
|
1032
|
+
input: 2,
|
|
1033
|
+
cacheHit: .57,
|
|
1034
|
+
output: 7
|
|
1035
|
+
}
|
|
1036
|
+
},
|
|
1025
1037
|
{
|
|
1026
1038
|
key: "glm-4.6",
|
|
1027
1039
|
name: "GLM-4.6",
|
|
@@ -1095,6 +1107,18 @@ const BUILTIN_MODEL_CATALOG = [
|
|
|
1095
1107
|
output: 22
|
|
1096
1108
|
}
|
|
1097
1109
|
},
|
|
1110
|
+
{
|
|
1111
|
+
key: "qwen4-max",
|
|
1112
|
+
name: "Qwen4 Max",
|
|
1113
|
+
provider: "阿里通义",
|
|
1114
|
+
colorVar: "dsw-static-blue-600",
|
|
1115
|
+
price: {
|
|
1116
|
+
currency: "CNY",
|
|
1117
|
+
input: 10,
|
|
1118
|
+
cacheHit: .5,
|
|
1119
|
+
output: 30
|
|
1120
|
+
}
|
|
1121
|
+
},
|
|
1098
1122
|
{
|
|
1099
1123
|
key: "qwen-3.8-max",
|
|
1100
1124
|
name: "Qwen3.8 Max",
|
|
@@ -1882,6 +1906,78 @@ const BUILTIN_MODEL_CATALOG = [
|
|
|
1882
1906
|
output: .5
|
|
1883
1907
|
}
|
|
1884
1908
|
},
|
|
1909
|
+
{
|
|
1910
|
+
key: "gpt-6.2-sol",
|
|
1911
|
+
name: "GPT-6.2 Sol",
|
|
1912
|
+
provider: "OpenAI",
|
|
1913
|
+
colorVar: "ds-green",
|
|
1914
|
+
price: {
|
|
1915
|
+
currency: "USD",
|
|
1916
|
+
input: 2,
|
|
1917
|
+
cacheHit: .1,
|
|
1918
|
+
output: 10
|
|
1919
|
+
}
|
|
1920
|
+
},
|
|
1921
|
+
{
|
|
1922
|
+
key: "gpt-6.2-astra",
|
|
1923
|
+
name: "GPT-6.2 Astra",
|
|
1924
|
+
provider: "OpenAI",
|
|
1925
|
+
colorVar: "ds-green",
|
|
1926
|
+
price: {
|
|
1927
|
+
currency: "USD",
|
|
1928
|
+
input: 8,
|
|
1929
|
+
cacheHit: .4,
|
|
1930
|
+
output: 40
|
|
1931
|
+
}
|
|
1932
|
+
},
|
|
1933
|
+
{
|
|
1934
|
+
key: "gpt-6.2-astra-healthcare",
|
|
1935
|
+
name: "GPT-6.2 Astra Healthcare",
|
|
1936
|
+
provider: "OpenAI",
|
|
1937
|
+
colorVar: "ds-green",
|
|
1938
|
+
price: {
|
|
1939
|
+
currency: "USD",
|
|
1940
|
+
input: 8,
|
|
1941
|
+
cacheHit: .4,
|
|
1942
|
+
output: 40
|
|
1943
|
+
}
|
|
1944
|
+
},
|
|
1945
|
+
{
|
|
1946
|
+
key: "gpt-6-astra-healthcare",
|
|
1947
|
+
name: "GPT-6 Astra Healthcare",
|
|
1948
|
+
provider: "OpenAI",
|
|
1949
|
+
colorVar: "ds-green",
|
|
1950
|
+
price: {
|
|
1951
|
+
currency: "USD",
|
|
1952
|
+
input: 10,
|
|
1953
|
+
cacheHit: 1,
|
|
1954
|
+
output: 50
|
|
1955
|
+
}
|
|
1956
|
+
},
|
|
1957
|
+
{
|
|
1958
|
+
key: "gpt-6.2-sol-healthcare",
|
|
1959
|
+
name: "GPT-6.2 Sol Healthcare",
|
|
1960
|
+
provider: "OpenAI",
|
|
1961
|
+
colorVar: "ds-green",
|
|
1962
|
+
price: {
|
|
1963
|
+
currency: "USD",
|
|
1964
|
+
input: 2,
|
|
1965
|
+
cacheHit: .1,
|
|
1966
|
+
output: 10
|
|
1967
|
+
}
|
|
1968
|
+
},
|
|
1969
|
+
{
|
|
1970
|
+
key: "gpt-6.1-sol-healthcare",
|
|
1971
|
+
name: "GPT-6.1 Sol Healthcare",
|
|
1972
|
+
provider: "OpenAI",
|
|
1973
|
+
colorVar: "ds-green",
|
|
1974
|
+
price: {
|
|
1975
|
+
currency: "USD",
|
|
1976
|
+
input: 2,
|
|
1977
|
+
cacheHit: .1,
|
|
1978
|
+
output: 10
|
|
1979
|
+
}
|
|
1980
|
+
},
|
|
1885
1981
|
{
|
|
1886
1982
|
key: "gpt-5.6-sol",
|
|
1887
1983
|
name: "GPT-5.6 Sol",
|
|
@@ -2543,6 +2639,42 @@ const BUILTIN_MODEL_CATALOG = [
|
|
|
2543
2639
|
output: 10
|
|
2544
2640
|
}
|
|
2545
2641
|
},
|
|
2642
|
+
{
|
|
2643
|
+
key: "gemini-4-neon",
|
|
2644
|
+
name: "Gemini 4 Neon",
|
|
2645
|
+
provider: "Google",
|
|
2646
|
+
colorVar: "dsw-static-blue-600",
|
|
2647
|
+
price: {
|
|
2648
|
+
currency: "USD",
|
|
2649
|
+
input: 3,
|
|
2650
|
+
cacheHit: .15,
|
|
2651
|
+
output: 15
|
|
2652
|
+
}
|
|
2653
|
+
},
|
|
2654
|
+
{
|
|
2655
|
+
key: "gemini-4-hydrogen",
|
|
2656
|
+
name: "Gemini 4 Hydrogen",
|
|
2657
|
+
provider: "Google",
|
|
2658
|
+
colorVar: "dsw-static-blue-600",
|
|
2659
|
+
price: {
|
|
2660
|
+
currency: "USD",
|
|
2661
|
+
input: 1.5,
|
|
2662
|
+
cacheHit: .075,
|
|
2663
|
+
output: 7.5
|
|
2664
|
+
}
|
|
2665
|
+
},
|
|
2666
|
+
{
|
|
2667
|
+
key: "gemini-4-carbon",
|
|
2668
|
+
name: "Gemini 4 Carbon",
|
|
2669
|
+
provider: "Google",
|
|
2670
|
+
colorVar: "dsw-static-blue-600",
|
|
2671
|
+
price: {
|
|
2672
|
+
currency: "USD",
|
|
2673
|
+
input: 2,
|
|
2674
|
+
cacheHit: .1,
|
|
2675
|
+
output: 10
|
|
2676
|
+
}
|
|
2677
|
+
},
|
|
2546
2678
|
{
|
|
2547
2679
|
key: "gemini-flash-latest",
|
|
2548
2680
|
name: "Gemini Flash Latest",
|
|
@@ -2795,6 +2927,18 @@ const BUILTIN_MODEL_CATALOG = [
|
|
|
2795
2927
|
output: 4.25
|
|
2796
2928
|
}
|
|
2797
2929
|
},
|
|
2930
|
+
{
|
|
2931
|
+
key: "muse-ember-1.0",
|
|
2932
|
+
name: "Muse Ember 1.0",
|
|
2933
|
+
provider: "Meta",
|
|
2934
|
+
colorVar: "ds-red",
|
|
2935
|
+
price: {
|
|
2936
|
+
currency: "USD",
|
|
2937
|
+
input: .1,
|
|
2938
|
+
cacheHit: .004,
|
|
2939
|
+
output: .5
|
|
2940
|
+
}
|
|
2941
|
+
},
|
|
2798
2942
|
{
|
|
2799
2943
|
key: "muse-spark-1.2",
|
|
2800
2944
|
name: "Muse Spark 1.2",
|
|
@@ -2951,6 +3095,18 @@ const BUILTIN_MODEL_CATALOG = [
|
|
|
2951
3095
|
output: 50
|
|
2952
3096
|
}
|
|
2953
3097
|
},
|
|
3098
|
+
{
|
|
3099
|
+
key: "claude-fable-5-2",
|
|
3100
|
+
name: "Claude Fable 5.2",
|
|
3101
|
+
provider: "Anthropic",
|
|
3102
|
+
colorVar: "ds-red",
|
|
3103
|
+
price: {
|
|
3104
|
+
currency: "USD",
|
|
3105
|
+
input: 8,
|
|
3106
|
+
cacheHit: .2,
|
|
3107
|
+
output: 40
|
|
3108
|
+
}
|
|
3109
|
+
},
|
|
2954
3110
|
{
|
|
2955
3111
|
key: "claude-fable-5",
|
|
2956
3112
|
name: "Claude Fable 5",
|
|
@@ -4327,7 +4483,20 @@ const BUILTIN_MODEL_KEY_ALIASES = {
|
|
|
4327
4483
|
"grok-4-6": "grok",
|
|
4328
4484
|
"gpt-image-2": "gpt-image-2",
|
|
4329
4485
|
"gpt-image-2.5-sunburst": "gpt-image-2.5-sunburst",
|
|
4330
|
-
"gpt-image-2-5-sunburst": "gpt-image-2.5-sunburst"
|
|
4486
|
+
"gpt-image-2-5-sunburst": "gpt-image-2.5-sunburst",
|
|
4487
|
+
"qwen4-max": "qwen4-max",
|
|
4488
|
+
"gpt-6.2-sol": "gpt-6.2-sol",
|
|
4489
|
+
"gpt-6.2-astra": "gpt-6.2-astra",
|
|
4490
|
+
"gpt-6.2-astra-healthcare": "gpt-6.2-astra-healthcare",
|
|
4491
|
+
"gpt-6-astra-healthcare": "gpt-6-astra-healthcare",
|
|
4492
|
+
"gpt-6.2-sol-healthcare": "gpt-6.2-sol-healthcare",
|
|
4493
|
+
"gpt-6.1-sol-healthcare": "gpt-6.1-sol-healthcare",
|
|
4494
|
+
"gemini-4-neon": "gemini-4-neon",
|
|
4495
|
+
"gemini-4-hydrogen": "gemini-4-hydrogen",
|
|
4496
|
+
"gemini-4-carbon": "gemini-4-carbon",
|
|
4497
|
+
"claude-fable-5-2": "claude-fable-5-2",
|
|
4498
|
+
"glm-5.3-flashx-legal": "glm-5.3-flashx-legal",
|
|
4499
|
+
"muse-ember-1.0": "muse-ember-1.0"
|
|
4331
4500
|
};
|
|
4332
4501
|
//#endregion
|
|
4333
4502
|
//#region lib/types/aggregate.js
|
|
@@ -7697,27 +7866,40 @@ const pricingGate = createCooldownGate({
|
|
|
7697
7866
|
cooldownMs: 6e4
|
|
7698
7867
|
});
|
|
7699
7868
|
/**
|
|
7700
|
-
*
|
|
7701
|
-
*
|
|
7702
|
-
*
|
|
7869
|
+
* 解析 `{ rates: { CNY: number } }` 结构的汇率 JSON(open.er-api.com 与 AllRatesToday 通用)。
|
|
7870
|
+
* @param text - 响应正文。
|
|
7871
|
+
* @returns CNY 汇率;结构不符或非正数时 undefined。
|
|
7703
7872
|
*/
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7873
|
+
function parseRatesJsonCny(text) {
|
|
7874
|
+
try {
|
|
7875
|
+
const cny = JSON.parse(text).rates?.CNY;
|
|
7876
|
+
return typeof cny === "number" && Number.isFinite(cny) && cny > 0 ? cny : void 0;
|
|
7877
|
+
} catch {
|
|
7878
|
+
return;
|
|
7709
7879
|
}
|
|
7710
|
-
}
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7880
|
+
}
|
|
7881
|
+
/**
|
|
7882
|
+
* USD → CNY 汇率源,按顺序尝试:国内可达的腾讯财经行情(免 key、`~` 分隔
|
|
7883
|
+
* 第 4 个字段为价格)优先,国外 open.er-api.com 兜底,再退到 AllRatesToday
|
|
7884
|
+
* 免 key 端点(同结构)。任一源失败自动落到下一个;全部失败由调用方降级内置汇率。
|
|
7885
|
+
*/
|
|
7886
|
+
const RATE_SOURCES = [
|
|
7887
|
+
{
|
|
7888
|
+
url: "https://qt.gtimg.cn/q=whUSDCNY",
|
|
7889
|
+
parse: (text) => {
|
|
7890
|
+
const price = /"([^"]*)"/.exec(text)?.[1]?.split("~")[3];
|
|
7891
|
+
return price !== void 0 && price !== "" ? Number(price) : void 0;
|
|
7718
7892
|
}
|
|
7893
|
+
},
|
|
7894
|
+
{
|
|
7895
|
+
url: "https://open.er-api.com/v6/latest/USD",
|
|
7896
|
+
parse: parseRatesJsonCny
|
|
7897
|
+
},
|
|
7898
|
+
{
|
|
7899
|
+
url: "https://allratestoday.com/api/open/latest/USD",
|
|
7900
|
+
parse: parseRatesJsonCny
|
|
7719
7901
|
}
|
|
7720
|
-
|
|
7902
|
+
];
|
|
7721
7903
|
/** OpenRouter's public model list: per-token USD prices, no key needed. */
|
|
7722
7904
|
const ROUTER_URL = "https://openrouter.ai/api/v1/models";
|
|
7723
7905
|
/** models.dev 公开目录:pi-ai 预制提供方的上游数据源(USD / 1M tokens)。
|
|
@@ -7822,25 +8004,25 @@ async function fetchJson(url) {
|
|
|
7822
8004
|
/** Latest USD → CNY rate from the first working source, or undefined when none respond. */
|
|
7823
8005
|
/**
|
|
7824
8006
|
* EUR → CNY 汇率源。与 USD 同一套降级约定:腾讯行情优先(免 key、国内可达),
|
|
7825
|
-
* open.er-api.com
|
|
8007
|
+
* open.er-api.com 兑底,AllRatesToday 再兜底;全部失败由调用方降级内置汇率,不阻塞其他价格拉取。
|
|
7826
8008
|
*/
|
|
7827
|
-
const EUR_RATE_SOURCES = [
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
}, {
|
|
7834
|
-
url: "https://open.er-api.com/v6/latest/EUR",
|
|
7835
|
-
parse: (text) => {
|
|
7836
|
-
try {
|
|
7837
|
-
const cny = JSON.parse(text).rates?.CNY;
|
|
7838
|
-
return typeof cny === "number" && Number.isFinite(cny) && cny > 0 ? cny : void 0;
|
|
7839
|
-
} catch {
|
|
7840
|
-
return;
|
|
8009
|
+
const EUR_RATE_SOURCES = [
|
|
8010
|
+
{
|
|
8011
|
+
url: "https://qt.gtimg.cn/q=whEURCNY",
|
|
8012
|
+
parse: (text) => {
|
|
8013
|
+
const price = /"([^"]*)"/.exec(text)?.[1]?.split("~")[3];
|
|
8014
|
+
return price !== void 0 && price !== "" ? Number(price) : void 0;
|
|
7841
8015
|
}
|
|
8016
|
+
},
|
|
8017
|
+
{
|
|
8018
|
+
url: "https://open.er-api.com/v6/latest/EUR",
|
|
8019
|
+
parse: parseRatesJsonCny
|
|
8020
|
+
},
|
|
8021
|
+
{
|
|
8022
|
+
url: "https://allratestoday.com/api/open/latest/EUR",
|
|
8023
|
+
parse: parseRatesJsonCny
|
|
7842
8024
|
}
|
|
7843
|
-
|
|
8025
|
+
];
|
|
7844
8026
|
/**
|
|
7845
8027
|
* 按顺序尝试汇率源,返回第一个合法正数。
|
|
7846
8028
|
* @param sources - 待尝试的汇率源。
|
|
@@ -9454,6 +9636,21 @@ function isLoopbackOrigin(origin) {
|
|
|
9454
9636
|
}
|
|
9455
9637
|
}
|
|
9456
9638
|
/**
|
|
9639
|
+
* 路由准入声明(宿主 0.2.3-alpha.1 起必需)。
|
|
9640
|
+
*
|
|
9641
|
+
* 宿主把 Web 路由的 `auth` 默认值从「无鉴权」改成了 `'required'`:未通过宿主
|
|
9642
|
+
* 连接层鉴权的请求在进入 handler **之前**就被拒(401/503),插件自带的守卫
|
|
9643
|
+
* 根本没机会执行——面板会静默变成一片 0。本插件的端点只服务本机浏览器,安全
|
|
9644
|
+
* 边界是 {@link guardLoopback}(peer 回环 socket + Host 头精确字面量 +
|
|
9645
|
+
* trustedHosts 白名单 + Origin 校验),因此显式声明匿名准入。
|
|
9646
|
+
*
|
|
9647
|
+
* 宿主的可信主机栅栏仍然生效(Host 必须是回环/可信主机、Origin 必须同源),
|
|
9648
|
+
* 这里只放宽「需要 peer 凭据」这一层,不放宽来源校验。
|
|
9649
|
+
*
|
|
9650
|
+
* 老宿主(≤0.2.2-rc.5)没有 `auth` 字段,多余字段被忽略,行为与从前一致。
|
|
9651
|
+
*/
|
|
9652
|
+
const ANONYMOUS_ROUTE_AUTH = { auth: "anonymous" };
|
|
9653
|
+
/**
|
|
9457
9654
|
* 回环防护守卫:仅接受回环 GET 请求(peer socket 地址 + Host 头同时校验)。
|
|
9458
9655
|
* 不满足时返回 403 并结束响应;调用方在 handler 顶部调用,返回 false 即已拒绝。
|
|
9459
9656
|
* @param req - 当前请求。
|
|
@@ -9498,6 +9695,7 @@ function registerNotifyClaimRoute(ctx, deps) {
|
|
|
9498
9695
|
ctx.effect(() => ctx.webServer.register({
|
|
9499
9696
|
kind: "exact",
|
|
9500
9697
|
path: "/api/billing/notify-claim",
|
|
9698
|
+
...ANONYMOUS_ROUTE_AUTH,
|
|
9501
9699
|
handler: async (req, res) => {
|
|
9502
9700
|
if (!guardLoopback(req, res, deps.trustedHosts)) return;
|
|
9503
9701
|
if (req.method !== "POST") {
|
|
@@ -9576,6 +9774,7 @@ function registerGetRoute(ctx, deps) {
|
|
|
9576
9774
|
ctx.effect(() => ctx.webServer.register({
|
|
9577
9775
|
kind: "exact",
|
|
9578
9776
|
path: "/api/billing/pricing",
|
|
9777
|
+
...ANONYMOUS_ROUTE_AUTH,
|
|
9579
9778
|
handler: async (req, res) => {
|
|
9580
9779
|
if (!guardLoopback(req, res, deps.trustedHosts)) return;
|
|
9581
9780
|
res.writeHead(200, { "content-type": "application/json; charset=utf-8" });
|
|
@@ -9588,6 +9787,7 @@ function registerRefreshRoute(ctx, deps) {
|
|
|
9588
9787
|
ctx.effect(() => ctx.webServer.register({
|
|
9589
9788
|
kind: "exact",
|
|
9590
9789
|
path: "/api/billing/pricing/refresh",
|
|
9790
|
+
...ANONYMOUS_ROUTE_AUTH,
|
|
9591
9791
|
handler: async (req, res) => {
|
|
9592
9792
|
if (!guardLoopback(req, res, deps.trustedHosts)) return;
|
|
9593
9793
|
if (req.method !== "POST") {
|
|
@@ -9635,6 +9835,7 @@ function registerBalanceRoute(ctx, deps) {
|
|
|
9635
9835
|
ctx.effect(() => ctx.webServer.register({
|
|
9636
9836
|
kind: "exact",
|
|
9637
9837
|
path: "/api/billing/balance",
|
|
9838
|
+
...ANONYMOUS_ROUTE_AUTH,
|
|
9638
9839
|
handler: async (req, res) => {
|
|
9639
9840
|
if (!guardLoopback(req, res, deps.trustedHosts)) return;
|
|
9640
9841
|
res.writeHead(200, { "content-type": "application/json; charset=utf-8" });
|
|
@@ -9682,6 +9883,7 @@ function registerUsageToolRoute(ctx, deps) {
|
|
|
9682
9883
|
ctx.effect(() => ctx.webServer.register({
|
|
9683
9884
|
kind: "exact",
|
|
9684
9885
|
path: "/api/billing/usage-tool",
|
|
9886
|
+
...ANONYMOUS_ROUTE_AUTH,
|
|
9685
9887
|
handler: async (req, res) => {
|
|
9686
9888
|
if (!guardLoopback(req, res, deps.trustedHosts)) return;
|
|
9687
9889
|
if (req.method !== "GET" && req.method !== "POST") {
|
|
@@ -9758,6 +9960,7 @@ function registerSubscriptionsRoute(ctx, deps) {
|
|
|
9758
9960
|
ctx.effect(() => ctx.webServer.register({
|
|
9759
9961
|
kind: "exact",
|
|
9760
9962
|
path: "/api/billing/subscriptions",
|
|
9963
|
+
...ANONYMOUS_ROUTE_AUTH,
|
|
9761
9964
|
handler: async (req, res) => {
|
|
9762
9965
|
if (!guardLoopback(req, res, deps.trustedHosts)) return;
|
|
9763
9966
|
res.writeHead(200, { "content-type": "application/json; charset=utf-8" });
|
|
@@ -9793,6 +9996,7 @@ function registerRelayQuotasRoute(ctx, deps) {
|
|
|
9793
9996
|
ctx.effect(() => ctx.webServer.register({
|
|
9794
9997
|
kind: "exact",
|
|
9795
9998
|
path: "/api/billing/relay-quotas",
|
|
9999
|
+
...ANONYMOUS_ROUTE_AUTH,
|
|
9796
10000
|
handler: async (req, res) => {
|
|
9797
10001
|
if (!guardLoopback(req, res, deps.trustedHosts)) return;
|
|
9798
10002
|
res.writeHead(200, { "content-type": "application/json; charset=utf-8" });
|
|
@@ -9926,6 +10130,7 @@ function registerUsageStatsRoute(ctx, deps) {
|
|
|
9926
10130
|
ctx.effect(() => ctx.webServer.register({
|
|
9927
10131
|
kind: "exact",
|
|
9928
10132
|
path: "/api/billing/usage-stats",
|
|
10133
|
+
...ANONYMOUS_ROUTE_AUTH,
|
|
9929
10134
|
handler: async (req, res) => {
|
|
9930
10135
|
if (!guardLoopback(req, res, deps.trustedHosts)) return;
|
|
9931
10136
|
res.writeHead(200, { "content-type": "application/json; charset=utf-8" });
|
|
@@ -10558,6 +10763,7 @@ function registerTaskQueueRoute(ctx, deps) {
|
|
|
10558
10763
|
ctx.effect(() => ctx.webServer.register({
|
|
10559
10764
|
kind: "exact",
|
|
10560
10765
|
path: "/api/billing/task-queue",
|
|
10766
|
+
...ANONYMOUS_ROUTE_AUTH,
|
|
10561
10767
|
handler: async (req, res) => {
|
|
10562
10768
|
if (!guardLoopback(req, res, deps.trustedHosts)) return;
|
|
10563
10769
|
if (req.method !== "GET" && req.method !== "POST") {
|
|
@@ -10630,6 +10836,7 @@ function registerTaskQueueRoute(ctx, deps) {
|
|
|
10630
10836
|
ctx.effect(() => ctx.webServer.register({
|
|
10631
10837
|
kind: "exact",
|
|
10632
10838
|
path: "/api/billing/task-queue-summary",
|
|
10839
|
+
...ANONYMOUS_ROUTE_AUTH,
|
|
10633
10840
|
handler: async (req, res) => {
|
|
10634
10841
|
if (!guardLoopback(req, res, deps.trustedHosts)) return;
|
|
10635
10842
|
if (req.method !== "GET") {
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 侧栏 footer 同槽占位测量(社区约定 §20.4 / §25「卡片型占用者」)。
|
|
3
|
+
*
|
|
4
|
+
* 背景:宿主的 `sidebar.footer.action` 是一个**无 wrap 的横向 flex 行**
|
|
5
|
+
* (`.footerActions{display:flex}`,无 gap/padding)。本插件的触发卡是**宽卡**
|
|
6
|
+
* (`width:100%`),同槽有别的插件时会把它们推到面板右边界之外——用户看到的
|
|
7
|
+
* 现象是「别的插件像没加载」(社区 issue #237)。纵向栈(手机端侧栏浮层)
|
|
8
|
+
* 下宽卡则会把同列的其它入口挤到下方(§25.6)。
|
|
9
|
+
*
|
|
10
|
+
* 宿主**不**向占位者暴露同槽邻居信息:owner props 只有 `{ wide }`,register
|
|
11
|
+
* 选项里也没有「占用者」字段(对比 `sidebar.panellist.actions` 才带 entries)。
|
|
12
|
+
* 因此按社区约定 §20.4 的测量算法从 DOM 反推:
|
|
13
|
+
* - 向上找到「真正的行」:跳过 `display:contents` 的槽位外壳;
|
|
14
|
+
* - 数同排的可见占位者(展开 display:contents 的子项,排除自己与不可见元素);
|
|
15
|
+
* - 读行的 `flex-direction`(`column` = 纵向栈)。
|
|
16
|
+
*
|
|
17
|
+
* 判定(§25 方案 A:卡片型占用者有邻居时降级为按钮形态):
|
|
18
|
+
* - 横向行且有邻居 → 收成 36×36 图标钮(此时禁止 `width:100%`);
|
|
19
|
+
* - 纵向栈 → 同样收成图标钮;
|
|
20
|
+
* - 其余(独占一行 / 测不到行)→ 保持宽卡。
|
|
21
|
+
*
|
|
22
|
+
* 本模块只做测量与判定,不碰宿主容器(不得注入 `flex-wrap` /
|
|
23
|
+
* `flex-direction` / `order`,见 §25 硬规则 2)。
|
|
24
|
+
*/
|
|
25
|
+
/** 同槽占位事实。 */
|
|
26
|
+
export interface FooterLaneFacts {
|
|
27
|
+
/** 真正的行容器(最近的 flex 祖先);找不到时为 null(此时没有横向挤占问题)。 */
|
|
28
|
+
row: HTMLElement | null;
|
|
29
|
+
/** 行是纵向列(手机端侧栏浮层)而非横向行。 */
|
|
30
|
+
stacked: boolean;
|
|
31
|
+
/** 同行可见占位者数量(不含自己)。 */
|
|
32
|
+
neighbors: number;
|
|
33
|
+
}
|
|
34
|
+
/** 触发卡形态:宽卡(独占一行)/ 图标钮(与邻居共存)。 */
|
|
35
|
+
export type TriggerForm = 'card' | 'icon';
|
|
36
|
+
/** 观察句柄。 */
|
|
37
|
+
export interface FooterLaneWatch {
|
|
38
|
+
/** 停止观察。 */
|
|
39
|
+
dispose(): void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 测量同槽占位事实。
|
|
43
|
+
* @param self - 本插件在行内的元素(触发卡外壳)。
|
|
44
|
+
* @returns 行容器 / 是否纵向栈 / 邻居数量。
|
|
45
|
+
*/
|
|
46
|
+
export declare function measureFooterLane(self: HTMLElement): FooterLaneFacts;
|
|
47
|
+
/**
|
|
48
|
+
* 由占位事实判定触发卡形态(社区约定 §25 方案 A)。
|
|
49
|
+
* @param facts - 同槽占位事实。
|
|
50
|
+
* @returns `icon` = 收成 36×36 图标钮;`card` = 保持宽卡。
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveTriggerForm(facts: FooterLaneFacts): TriggerForm;
|
|
53
|
+
/**
|
|
54
|
+
* 观察同槽占位变化,形态变化时回调。
|
|
55
|
+
*
|
|
56
|
+
* 三路触发源缺一不可(§20.4):`ResizeObserver`(侧栏拖拽改宽 / 折叠)、
|
|
57
|
+
* `MutationObserver`(邻居插件注册、卸载、隐藏)、`window` `resize`。
|
|
58
|
+
* 只在**形态真的变了**时回调,避免自触发成环。
|
|
59
|
+
*
|
|
60
|
+
* @param self - 本插件在行内的元素。
|
|
61
|
+
* @param onForm - 形态变化回调。
|
|
62
|
+
* @returns 观察句柄。
|
|
63
|
+
*/
|
|
64
|
+
export declare function watchFooterLane(self: HTMLElement, onForm: (form: TriggerForm) => void): FooterLaneWatch;
|
|
65
|
+
//# sourceMappingURL=footer-lane.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Locale dictionaries for the usage billing surface. */
|
|
2
|
-
export type UsageBillingKey = 'title' | 'cost' | 'todayCost' | 'monthCost' | 'yearCost' | 'monthProjected' | 'monthProjectedHint' | 'liveTurn' | 'liveSession' | 'liveSessionSub' | 'calls' | 'cacheHitRate' | 'tokens' | 'inputTokens' | 'outputTokens' | 'avgCost' | 'kpiRange' | 'avgRangeToday' | 'avgRange7d' | 'avgRangeWeek' | 'avgRangeMonth' | 'avgRangeAll' | 'avgRangeCustom' | 'customRangeStart' | 'customRangeEnd' | 'trend' | 'trend7d' | 'trend30d' | 'trendMetric' | 'trendMetricCost' | 'trendMetricTokens' | 'pricingSearch' | 'bandPinHint' | 'trendEmpty' | 'trendTotal' | 'roundsUnit' | 'healthModelsLive' | 'healthVendorsDown' | 'healthVendorsUnavailable' | 'budget' | 'budgetRemain' | 'budgetAmount' | 'budgetSummary' | 'sessions' | 'sessionTitle' | 'lastActive' | 'sessionOverflow' | 'budgetTierBody' | 'models' | 'providerBilling' | 'channelUnknown' | 'directTag' | 'relayTag' | 'unknownTag' | 'unknownChannelHint' | 'planCountUnit' | 'actual' | 'pricing' | 'input' | 'output' | 'cacheHit' | 'peak' | 'offPeak' | 'flat' | 'band' | 'close' | 'footer' | 'footerCredit' | 'lastUpdated' | 'noData' | 'todayRate' | 'rateLive' | 'rateBuiltin' | 'pricingSyncedAt' | 'pricingSyncNow' | 'pricingSyncing' | 'promoBadge' | 'promoUntil' | 'promoOpenEnded' | 'pricingTip' | 'pricingUnit' | 'pricingNotes' | 'ubPeak' | 'ubOff' | 'ubStd' | 'peakBand' | 'pricingSource' | 'noteCache' | 'noteBand' | 'noteSource' | 'balance' | 'recharge' | 'rechargeHint' | 'balanceUnconfigured' | 'balanceUnauthorized' | 'balanceUnreachable' | 'uncatalogued' | 'estimatedPricing' | 'balanceDays' | 'balanceLowBody' | 'reconcileDrift' | 'reconcileDismiss' | 'subscriptionNotConfigured' | 'subscriptionUnauthorized' | 'subscriptionUnavailable' | 'subscriptionInvalid' | 'subscriptionRateLimited' | 'subscriptionSession' | 'subscriptionWeekly' | 'subscriptionMonthly' | 'subscriptionBilling' | 'subscriptionRemaining' | 'subscriptionExhausted' | 'subscriptionReset' | 'subscriptionNoApi' | 'floatWindow' | 'floatModeCombined' | 'floatModeSubscription' | 'floatMode' | 'floatTargets' | 'floatWindowHint' | 'floatPrimaryToday' | 'floatPrimaryWeek' | 'floatPrimaryMonth' | 'floatNoTargets' | 'floatNoTargetsHint' | 'cardDisplay' | 'cardDisplayHint' | 'cardMode' | 'cardModeFull' | 'cardModeCompact' | 'cardModeHidden' | 'cardModeHiddenHint' | 'cardModeFallback' | 'nativeSettingsNav' | 'nativeSettingsIntro' | 'nativeSettingsHiddenHint' | 'cardMetric' | 'cardMetricMoney' | 'cardMetricTokens' | 'cardSpan' | 'cardSpanDay' | 'cardSpanWeek' | 'cardSpanMonth' | 'cardDeltaBadge' | 'cardDeltaShow' | 'cardDeltaHide' | 'triggerMonthTokens' | 'triggerTodayTokens' | 'triggerWeekTokens' | 'subscriptionsStale' | 'balanceStaleNotice' | 'staleLedgerNotice' | 'staleSnapshotNotice' | 'statsLoadFailed' | 'unreadableNotice' | 'unreadableFormatNotice' | 'unreadableNoLedgerNotice' | 'tokenCacheWrite' | 'toolRank' | 'toolName' | 'userPrices' | 'userPricesHint' | 'userPriceSave' | 'userPriceModel' | 'userPriceSource' | 'userPriceSourceHint' | 'userPriceOffPeak' | 'userPriceNormal' | 'userPriceCurrency' | 'userPriceAdd' | 'userPriceRemoveSelected' | 'userPriceSelect' | 'sessionStaleBadge' | 'sessionUntitled' | 'sessionSubCost' | 'sessionSubCalls' | 'sessionSubRow' | 'heatmapLess' | 'heatmapMore' | 'currency' | 'currencyCny' | 'currencyUsd' | 'currencyEur' | 'language' | 'heatmap' | 'rounds' | 'roundsHint' | 'anomaly' | 'model' | 'thModel' | 'thInputMiss' | 'thInputHit' | 'costAbbr' | 'tabOverview' | 'tabTrends' | 'tabProviders' | 'tabPricing' | 'tabSettings' | 'budgetHint' | 'peakAlertHint' | 'peakAlertDescPeak' | 'peakAlertDescOff' | 'peakAlertDescPeakZhipu' | 'peakAlertDescOffZhipu' | 'peakAlertQueuePeak' | 'peakAlertQueueOff' | 'export' | 'exportCsvDay' | 'exportCsvSession' | 'exportJson' | 'peakShare' | 'peakSharePerCall' | 'offPeakSavings' | 'perfMax' | 'weekCost' | 'roleCost' | 'roleUser' | 'roleAssistant' | 'roleTool' | 'roleHint' | 'tierPeak' | 'tierOff' | 'tierToPeak' | 'tierToOff' | 'tierAlertEnterPeak' | 'tierAlertEnterOff' | 'tierAlertEnterPeakZhipu' | 'tierAlertEnterOffZhipu' | 'peakAlertTitlePeak' | 'peakAlertTitleOff' | 'peakAlert' | 'peakAlertLeadMin' | 'peakAlertPos' | 'peakAlertMode' | 'peakAlertPosCorner' | 'peakAlertPosCenter' | 'peakAlertModePeak' | 'peakAlertModeOff' | 'peakAlertModeBoth' | 'peakAlertWebNotify' | 'peakAlertPreview' | 'planTypeCode' | 'planTypeToken' | 'subscriptionFeePerMonth' | 'triggerToday' | 'triggerMonth' | 'subscriptionTag' | 'cellEstimateHint' | 'free' | 'perfSamples' | 'perfTtft' | 'perfP50' | 'perfP90' | 'perfTps' | 'perfLatency' | 'perfEstimated' | 'perfEmpty' | 'perfTpsUnit' | 'perfTitle' | 'perfHint' | 'perfAll' | 'perfChartEmpty' | 'heatmapYear' | 'heatmapHalf' | 'heatmapMonth' | 'metricCost' | 'metricTokens' | 'heatmapTotal' | 'activeDays' | 'streakDays' | 'subscriptionAutoDetect' | 'pluginAuthor' | 'pluginRepository' | 'pluginNpm' | 'pluginLicense' | 'tabToken' | 'tokenExport' | 'tokenExportCsv' | 'tokenReasoningShare' | 'tokenReasoningShort' | 'tokenIo' | 'tokenPeak' | 'densityLabel' | 'densityHint' | 'densityCompact' | 'densityDefault' | 'densityComfortable' | 'motionLabel' | 'motionHint' | 'motionOff' | 'motionSubtle' | 'motionRich' | 'settingsNavDisplayPref' | 'settingsNavBudget' | 'settingsNavAlert' | 'settingsNavDisplay' | 'settingsNavAdvanced' | 'settingsNavAbout' | 'settingsSearchPlaceholder' | 'settingsSearchEmpty' | 'sessionsViewAll' | 'sessionsViewTop' | 'sessionViewerSearch' | 'modelBudgetTitle' | 'modelBudgetHint' | 'modelBudgetBody' | 'modelBudgetPlaceholder' | 'moreWorksTitle' | 'adEngramName' | 'adEngramDesc' | 'adRainbowName' | 'adRainbowDesc' | 'kpiDescCacheHit' | 'kpiDescTokens' | 'kpiDescAvgCost' | 'kpiDescCalls' | 'kpiDescReasoning' | 'kpiDescIo' | 'kpiDescPeak' | 'healthDotLive' | 'healthDotFailed' | 'healthDotUnknown' | 'settingsSectionDisplay' | 'emptyHint' | 'tokenDaily' | 'tokenByModel' | 'tokenMiss' | 'tokenHit' | 'tokenOutput' | 'tokenViewStructure' | 'tokenViewModel' | 'tokenHitShort' | 'tokenMissShort' | 'tokenTotal' | 'tokenShare' | 'usageStatsTool' | 'usageStatsToolHint' | 'balanceGranted' | 'balanceTopped' | 'balanceDaily' | 'balanceDaysLong' | 'balanceDaysUnit' | 'popTodayModel' | 'popNoConsumption' | 'popTitle' | 'popDirectLead' | 'popSubLead' | 'unpricedHint' | 'channelVisibility' | 'channelVisibilityHint' | 'channelVisibilityShowAll' | 'channelVisibilityHidden' | 'channelVisibilityEmpty' | 'unpricedMore' | 'unpricedFix' | 'searchEstimateHint' | 'siteListDisplay' | 'siteListDisplayHint' | 'liveCostBar' | 'liveCostBarHint' | 'liveCostBarPosition' | 'liveCostBarPosBelow' | 'liveCostBarPosAbove' | 'liveCostBarPosToolbar' | 'exportCsvSite' | 'panelRelayQuota' | 'relayBalance' | 'relayNoQuota' | 'relayWindowUsed' | 'relayKindNewApi' | 'relayKindSub2Api' | 'relayKindUnknown' | 'expandAll' | 'collapseAll' | 'todayOnly' | 'todayNoConsumption' | 'commandUsageLabel' | 'commandUsageDescription' | 'sessionOpen' | 'sessionOpenFailed' | 'sessionOpenUnavailable' | 'tabAgents' | 'tabQueue' | 'queueSubtitle' | 'queueUntilPeak' | 'queueUntilOffPeak' | 'queueUnsupportedTitle' | 'queueUnsupportedBody' | 'queueSafety' | 'queueSafetyIsolated' | 'queueSafetyReuse' | 'queueReusePlanned' | 'queueReuseDone' | 'queueFallbackReason' | 'queueReuseModelNote' | 'queueWorkspace' | 'queueModel' | 'queueNoOptions' | 'queuePromptLabel' | 'queuePromptPlaceholder' | 'queuePrivacy' | 'queueEnqueue' | 'queueImport' | 'queueImportHint' | 'queueImported' | 'queueImportFormat' | 'queueImportTooLarge' | 'queueActive' | 'queueClearFinished' | 'queueEmpty' | 'queueLoading' | 'queueOpenSession' | 'queueRemoveQueued' | 'queueRemoveHistory' | 'queueStatusQueued' | 'queueStatusStarting' | 'queueStatusRunning' | 'queueStatusCompleted' | 'queueStatusFailed' | 'quickQueueToggle' | 'quickQueueEntry' | 'quickQueueEntryHint' | 'quickQueueReuseEntry' | 'quickQueueReuseEntryHint' | 'quickQueueEnqueue' | 'quickQueueEnqueueing' | 'quickQueueWaiting' | 'quickQueueClear' | 'quickQueueEnqueued' | 'quickQueueEmpty' | 'quickQueueBusy' | 'quickQueueAttachments' | 'quickQueueContext' | 'quickQueueRoute' | 'quickQueueDraftChanged' | 'quickQueueUnsupported' | 'quickQueueFailed' | 'agentsSummary' | 'agentsCount' | 'agentsDelegations' | 'agentsRoots' | 'agentsMostExpensive' | 'agentsChainTotal' | 'agentsNoData' | 'agentsSubagent' | 'agentsRoot';
|
|
2
|
+
export type UsageBillingKey = 'title' | 'cost' | 'todayCost' | 'monthCost' | 'yearCost' | 'monthProjected' | 'monthProjectedHint' | 'liveTurn' | 'liveSession' | 'liveSessionSub' | 'calls' | 'cacheHitRate' | 'tokens' | 'inputTokens' | 'outputTokens' | 'avgCost' | 'kpiRange' | 'avgRangeToday' | 'avgRange7d' | 'avgRangeWeek' | 'avgRangeMonth' | 'avgRangeAll' | 'avgRangeCustom' | 'customRangeStart' | 'customRangeEnd' | 'trend' | 'trend7d' | 'trend30d' | 'trendMetric' | 'trendMetricCost' | 'trendMetricTokens' | 'pricingSearch' | 'bandPinHint' | 'trendEmpty' | 'trendTotal' | 'roundsUnit' | 'healthModelsLive' | 'healthVendorsDown' | 'healthVendorsUnavailable' | 'budget' | 'budgetRemain' | 'budgetAmount' | 'budgetSummary' | 'sessions' | 'sessionTitle' | 'lastActive' | 'sessionOverflow' | 'budgetTierBody' | 'models' | 'providerBilling' | 'channelUnknown' | 'directTag' | 'relayTag' | 'unknownTag' | 'unknownChannelHint' | 'planCountUnit' | 'actual' | 'pricing' | 'input' | 'output' | 'cacheHit' | 'peak' | 'offPeak' | 'flat' | 'band' | 'close' | 'footer' | 'footerCredit' | 'lastUpdated' | 'noData' | 'todayRate' | 'rateLive' | 'rateBuiltin' | 'pricingSyncedAt' | 'pricingSyncNow' | 'pricingSyncing' | 'promoBadge' | 'promoUntil' | 'promoOpenEnded' | 'pricingTip' | 'pricingUnit' | 'pricingNotes' | 'ubPeak' | 'ubOff' | 'ubStd' | 'peakBand' | 'pricingSource' | 'noteCache' | 'noteBand' | 'noteSource' | 'balance' | 'recharge' | 'rechargeHint' | 'balanceUnconfigured' | 'balanceUnauthorized' | 'balanceUnreachable' | 'uncatalogued' | 'estimatedPricing' | 'balanceDays' | 'balanceLowBody' | 'reconcileDrift' | 'reconcileDismiss' | 'subscriptionNotConfigured' | 'subscriptionUnauthorized' | 'subscriptionUnavailable' | 'subscriptionInvalid' | 'subscriptionRateLimited' | 'subscriptionSession' | 'subscriptionWeekly' | 'subscriptionMonthly' | 'subscriptionBilling' | 'subscriptionRemaining' | 'subscriptionExhausted' | 'subscriptionReset' | 'subscriptionNoApi' | 'floatWindow' | 'floatModeCombined' | 'floatModeSubscription' | 'floatMode' | 'floatTargets' | 'floatWindowHint' | 'floatPrimaryToday' | 'floatPrimaryWeek' | 'floatPrimaryMonth' | 'floatNoTargets' | 'floatNoTargetsHint' | 'cardDisplay' | 'cardDisplayHint' | 'cardMode' | 'cardModeFull' | 'cardModeCompact' | 'cardModeHidden' | 'cardModeHiddenHint' | 'cardModeFallback' | 'nativeSettingsNav' | 'nativeSettingsIntro' | 'nativeSettingsHiddenHint' | 'shortcutOpenDashboard' | 'cardMetric' | 'cardMetricMoney' | 'cardMetricTokens' | 'cardSpan' | 'cardSpanDay' | 'cardSpanWeek' | 'cardSpanMonth' | 'cardDeltaBadge' | 'cardDeltaShow' | 'cardDeltaHide' | 'triggerMonthTokens' | 'triggerTodayTokens' | 'triggerWeekTokens' | 'subscriptionsStale' | 'balanceStaleNotice' | 'staleLedgerNotice' | 'staleSnapshotNotice' | 'statsLoadFailed' | 'unreadableNotice' | 'unreadableFormatNotice' | 'unreadableNoLedgerNotice' | 'tokenCacheWrite' | 'toolRank' | 'toolName' | 'userPrices' | 'userPricesHint' | 'userPriceSave' | 'userPriceModel' | 'userPriceSource' | 'userPriceSourceHint' | 'userPriceOffPeak' | 'userPriceNormal' | 'userPriceCurrency' | 'userPriceAdd' | 'userPriceRemoveSelected' | 'userPriceSelect' | 'sessionStaleBadge' | 'sessionUntitled' | 'sessionSubCost' | 'sessionSubCalls' | 'sessionSubRow' | 'heatmapLess' | 'heatmapMore' | 'currency' | 'currencyCny' | 'currencyUsd' | 'currencyEur' | 'language' | 'heatmap' | 'rounds' | 'roundsHint' | 'anomaly' | 'model' | 'thModel' | 'thInputMiss' | 'thInputHit' | 'costAbbr' | 'tabOverview' | 'tabTrends' | 'tabProviders' | 'tabPricing' | 'tabSettings' | 'budgetHint' | 'peakAlertHint' | 'peakAlertDescPeak' | 'peakAlertDescOff' | 'peakAlertDescPeakZhipu' | 'peakAlertDescOffZhipu' | 'peakAlertQueuePeak' | 'peakAlertQueueOff' | 'export' | 'exportCsvDay' | 'exportCsvSession' | 'exportJson' | 'peakShare' | 'peakSharePerCall' | 'offPeakSavings' | 'perfMax' | 'weekCost' | 'roleCost' | 'roleUser' | 'roleAssistant' | 'roleTool' | 'roleHint' | 'tierPeak' | 'tierOff' | 'tierToPeak' | 'tierToOff' | 'tierAlertEnterPeak' | 'tierAlertEnterOff' | 'tierAlertEnterPeakZhipu' | 'tierAlertEnterOffZhipu' | 'peakAlertTitlePeak' | 'peakAlertTitleOff' | 'peakAlert' | 'peakAlertLeadMin' | 'peakAlertPos' | 'peakAlertMode' | 'peakAlertPosCorner' | 'peakAlertPosCenter' | 'peakAlertModePeak' | 'peakAlertModeOff' | 'peakAlertModeBoth' | 'peakAlertWebNotify' | 'peakAlertPreview' | 'planTypeCode' | 'planTypeToken' | 'subscriptionFeePerMonth' | 'triggerToday' | 'triggerMonth' | 'subscriptionTag' | 'cellEstimateHint' | 'free' | 'perfSamples' | 'perfTtft' | 'perfP50' | 'perfP90' | 'perfTps' | 'perfLatency' | 'perfEstimated' | 'perfEmpty' | 'perfTpsUnit' | 'perfTitle' | 'perfHint' | 'perfAll' | 'perfChartEmpty' | 'heatmapYear' | 'heatmapHalf' | 'heatmapMonth' | 'metricCost' | 'metricTokens' | 'heatmapTotal' | 'activeDays' | 'streakDays' | 'subscriptionAutoDetect' | 'pluginAuthor' | 'pluginRepository' | 'pluginNpm' | 'pluginLicense' | 'tabToken' | 'tokenExport' | 'tokenExportCsv' | 'tokenReasoningShare' | 'tokenReasoningShort' | 'tokenIo' | 'tokenPeak' | 'densityLabel' | 'densityHint' | 'densityCompact' | 'densityDefault' | 'densityComfortable' | 'motionLabel' | 'motionHint' | 'motionOff' | 'motionSubtle' | 'motionRich' | 'settingsNavDisplayPref' | 'settingsNavBudget' | 'settingsNavAlert' | 'settingsNavDisplay' | 'settingsNavAdvanced' | 'settingsNavAbout' | 'settingsSearchPlaceholder' | 'settingsSearchEmpty' | 'sessionsViewAll' | 'sessionsViewTop' | 'sessionViewerSearch' | 'modelBudgetTitle' | 'modelBudgetHint' | 'modelBudgetBody' | 'modelBudgetPlaceholder' | 'moreWorksTitle' | 'adEngramName' | 'adEngramDesc' | 'adRainbowName' | 'adRainbowDesc' | 'kpiDescCacheHit' | 'kpiDescTokens' | 'kpiDescAvgCost' | 'kpiDescCalls' | 'kpiDescReasoning' | 'kpiDescIo' | 'kpiDescPeak' | 'healthDotLive' | 'healthDotFailed' | 'healthDotUnknown' | 'settingsSectionDisplay' | 'emptyHint' | 'tokenDaily' | 'tokenByModel' | 'tokenMiss' | 'tokenHit' | 'tokenOutput' | 'tokenViewStructure' | 'tokenViewModel' | 'tokenHitShort' | 'tokenMissShort' | 'tokenTotal' | 'tokenShare' | 'usageStatsTool' | 'usageStatsToolHint' | 'balanceGranted' | 'balanceTopped' | 'balanceDaily' | 'balanceDaysLong' | 'balanceDaysUnit' | 'popTodayModel' | 'popNoConsumption' | 'popTitle' | 'popDirectLead' | 'popSubLead' | 'unpricedHint' | 'channelVisibility' | 'channelVisibilityHint' | 'channelVisibilityShowAll' | 'channelVisibilityHidden' | 'channelVisibilityEmpty' | 'unpricedMore' | 'unpricedFix' | 'searchEstimateHint' | 'siteListDisplay' | 'siteListDisplayHint' | 'liveCostBar' | 'liveCostBarHint' | 'liveCostBarPosition' | 'liveCostBarPosBelow' | 'liveCostBarPosAbove' | 'liveCostBarPosToolbar' | 'exportCsvSite' | 'panelRelayQuota' | 'relayBalance' | 'relayNoQuota' | 'relayWindowUsed' | 'relayKindNewApi' | 'relayKindSub2Api' | 'relayKindUnknown' | 'expandAll' | 'collapseAll' | 'todayOnly' | 'todayNoConsumption' | 'commandUsageLabel' | 'commandUsageDescription' | 'sessionOpen' | 'sessionOpenFailed' | 'sessionOpenUnavailable' | 'tabAgents' | 'tabQueue' | 'queueSubtitle' | 'queueUntilPeak' | 'queueUntilOffPeak' | 'queueUnsupportedTitle' | 'queueUnsupportedBody' | 'queueSafety' | 'queueSafetyIsolated' | 'queueSafetyReuse' | 'queueReusePlanned' | 'queueReuseDone' | 'queueFallbackReason' | 'queueReuseModelNote' | 'queueWorkspace' | 'queueModel' | 'queueNoOptions' | 'queuePromptLabel' | 'queuePromptPlaceholder' | 'queuePrivacy' | 'queueEnqueue' | 'queueImport' | 'queueImportHint' | 'queueImported' | 'queueImportFormat' | 'queueImportTooLarge' | 'queueActive' | 'queueClearFinished' | 'queueEmpty' | 'queueLoading' | 'queueOpenSession' | 'queueRemoveQueued' | 'queueRemoveHistory' | 'queueStatusQueued' | 'queueStatusStarting' | 'queueStatusRunning' | 'queueStatusCompleted' | 'queueStatusFailed' | 'quickQueueToggle' | 'quickQueueEntry' | 'quickQueueEntryHint' | 'quickQueueReuseEntry' | 'quickQueueReuseEntryHint' | 'quickQueueEnqueue' | 'quickQueueEnqueueing' | 'quickQueueWaiting' | 'quickQueueClear' | 'quickQueueEnqueued' | 'quickQueueEmpty' | 'quickQueueBusy' | 'quickQueueAttachments' | 'quickQueueContext' | 'quickQueueRoute' | 'quickQueueDraftChanged' | 'quickQueueUnsupported' | 'quickQueueFailed' | 'agentsSummary' | 'agentsCount' | 'agentsDelegations' | 'agentsRoots' | 'agentsMostExpensive' | 'agentsChainTotal' | 'agentsNoData' | 'agentsSubagent' | 'agentsRoot';
|
|
3
3
|
export declare const NS = "usageBilling";
|
|
4
4
|
export declare const zh: Record<UsageBillingKey, string>;
|
|
5
5
|
export declare const en: Record<UsageBillingKey, string>;
|
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
* - `label` / `description` 是**函数**:菜单每次打开都重新读取,切换语言立即生效,
|
|
11
11
|
* 无需重新注册。
|
|
12
12
|
*
|
|
13
|
-
* 取服务走 `ctx.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* 取服务走 `ctx.inject(['commandUi'])` 而非 apply 期的 `ctx.get`:该服务是宿主的
|
|
14
|
+
* Service,要等 inputTriggers / remote.commands 就绪才构造,晚于本插件 apply。
|
|
15
|
+
* 老宿主没有这个服务时注入分支永不执行,**不注册命令**、面板功能完全不受影响——
|
|
16
|
+
* 这是「服务缺席即降级、不得因此收窄兼容矩阵」的落点。
|
|
16
17
|
*/
|
|
17
18
|
import type { Context } from '@deepseek-ai/cordis';
|
|
18
19
|
/** 命令名(斜杠后不带斜杠):与宿主命令目录合并的键。 */
|
|
@@ -29,9 +30,13 @@ export interface UsageCommandOptions {
|
|
|
29
30
|
/**
|
|
30
31
|
* 注册 `/usage` 命令。
|
|
31
32
|
*
|
|
33
|
+
* commandUi 是宿主的 Service,构造前要等 inputTriggers / sessions / remote.commands
|
|
34
|
+
* 就绪——这些都晚于本插件 apply。因此在 apply 期用 `ctx.get` 一次性采样必然拿到
|
|
35
|
+
* undefined,命令永远注册不上;改为 `ctx.inject` 等它就位再注册。
|
|
36
|
+
*
|
|
32
37
|
* @param ctx - 客户端根 context。
|
|
33
38
|
* @param options - 打开回调与文案。
|
|
34
|
-
* @returns
|
|
39
|
+
* @returns 查询当前是否已注册的 getter(宿主无 commandUi 服务时恒为 false,属正常降级)。
|
|
35
40
|
*/
|
|
36
|
-
export declare function registerUsageCommand(ctx: Context, options: UsageCommandOptions): boolean;
|
|
41
|
+
export declare function registerUsageCommand(ctx: Context, options: UsageCommandOptions): () => boolean;
|
|
37
42
|
//# sourceMappingURL=usage-command.d.ts.map
|
package/lib/types/guard.d.ts
CHANGED
|
@@ -38,6 +38,23 @@ export declare function isLoopbackHost(req: IncomingMessage, trustedHosts?: Read
|
|
|
38
38
|
* (curl 或同源 fetch 不带)视为放行,交给下方的 Content-Type 校验兜底;Origin 存在
|
|
39
39
|
* 但主机非回环则拒绝——跨站脚本发起的写请求必带攻击者域名的 Origin。 */
|
|
40
40
|
export declare function isLoopbackOrigin(origin: string | undefined): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* 路由准入声明(宿主 0.2.3-alpha.1 起必需)。
|
|
43
|
+
*
|
|
44
|
+
* 宿主把 Web 路由的 `auth` 默认值从「无鉴权」改成了 `'required'`:未通过宿主
|
|
45
|
+
* 连接层鉴权的请求在进入 handler **之前**就被拒(401/503),插件自带的守卫
|
|
46
|
+
* 根本没机会执行——面板会静默变成一片 0。本插件的端点只服务本机浏览器,安全
|
|
47
|
+
* 边界是 {@link guardLoopback}(peer 回环 socket + Host 头精确字面量 +
|
|
48
|
+
* trustedHosts 白名单 + Origin 校验),因此显式声明匿名准入。
|
|
49
|
+
*
|
|
50
|
+
* 宿主的可信主机栅栏仍然生效(Host 必须是回环/可信主机、Origin 必须同源),
|
|
51
|
+
* 这里只放宽「需要 peer 凭据」这一层,不放宽来源校验。
|
|
52
|
+
*
|
|
53
|
+
* 老宿主(≤0.2.2-rc.5)没有 `auth` 字段,多余字段被忽略,行为与从前一致。
|
|
54
|
+
*/
|
|
55
|
+
export declare const ANONYMOUS_ROUTE_AUTH: {
|
|
56
|
+
readonly auth: "anonymous";
|
|
57
|
+
};
|
|
41
58
|
/**
|
|
42
59
|
* 回环防护守卫:仅接受回环 GET 请求(peer socket 地址 + Host 头同时校验)。
|
|
43
60
|
* 不满足时返回 403 并结束响应;调用方在 handler 顶部调用,返回 false 即已拒绝。
|