@rayadesu/dsh-client-ui-billing 0.2.0 → 0.2.2
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.i18n.yaml +2 -2
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/lib/client.js +97 -82
- package/lib/types/client/BalanceBadge.d.ts +7 -6
- package/lib/types/client/index.d.ts +1 -1
- package/package.json +32 -21
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# last confirmed-consistent state. Both languages carry equal authority; after
|
|
3
3
|
# editing either side, bring the other along and re-record both hashes with:
|
|
4
4
|
# git hash-object README.md README.zh.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 0856ee1b93e49f34da5f534ce189568b8157d157
|
|
6
|
+
README.zh.md: 80a4334b4eaf79636fbdad0ce9484f07dfb1f8e0
|
package/README.md
CHANGED
|
@@ -12,9 +12,9 @@ The badge is account-level even though the slot is session-scoped: the header ut
|
|
|
12
12
|
|
|
13
13
|
The spends follow the conversation and the balance stays a manual snapshot:
|
|
14
14
|
|
|
15
|
-
- **Spends follow
|
|
15
|
+
- **Spends follow settled turns, debounced** — the component subscribes to the current session's running flag through the framework `useSession` seat. When a prompt turn settles (the flag flips back to idle), it recomputes this session's spend (`billing/getSessionSpend`) and today's spend (`billing/getTodaySpend`), local pricing passes with no network request, so the spend lines stay live during an ongoing conversation. The recompute is debounced for two seconds, so a burst of turns (an agent continuing across turns) prices once instead of once per turn; the host-side cache (see `dsh-llm-billing`) then serves the first miss for the rest of the minute.
|
|
16
16
|
- **Balance is manual** — the account balance is fetched on mount, on session switch, and on the explicit refresh action (`billing/getBalance`). There is no polling and no automatic refetch: the balance line only changes when one of those events happens.
|
|
17
|
-
- **Refresh keeps the last values** — an in-flight refresh leaves the previous values on screen, and a failed refresh retains the last good value instead of blanking it. The refresh action calls `billing/getTodaySpend(true)`, which bypasses the host-side cache; the
|
|
17
|
+
- **Refresh keeps the last values** — an in-flight refresh leaves the previous values on screen, and a failed refresh retains the last good value instead of blanking it. The refresh action calls `billing/getTodaySpend(true)`, which bypasses the host-side cache; the turn-triggered recompute and the mount/session-switch read use the cached path.
|
|
18
18
|
|
|
19
19
|
## Model Experience
|
|
20
20
|
|
package/README.zh.md
CHANGED
|
@@ -12,9 +12,9 @@ Web 额度特性的归属方:向 `conversation.session.header.utilities` 贡
|
|
|
12
12
|
|
|
13
13
|
花费跟随会话、额度保持手动快照:
|
|
14
14
|
|
|
15
|
-
-
|
|
15
|
+
- **花费随回合结束自动更新(去抖)** —— 组件通过框架 `useSession` 座位订阅当前会话的「运行中」标志。每当一轮 prompt 回合结束(标志翻回空闲),就只重算**本会话的花费**(`billing/getSessionSpend`)与**今日共花费**(`billing/getTodaySpend`,纯本地计价、不发网络请求),连续对话时花费行实时跟随。重算有 2 秒去抖,回合突发(agent 连续多轮)只计价一次;宿主侧缓存(见 `dsh-llm-billing`)随后在一分钟内服务首次未命中。
|
|
16
16
|
- **额度保持手动** —— 账户余额在挂载、切换会话、点刷新按钮时拉取(`billing/getBalance`)。**没有轮询、不会自动重拉**:余额行只在这几个时机变化。
|
|
17
|
-
- **刷新保留旧值** —— 刷新在途时旧值留在屏幕上,刷新失败保留上一次有效值,不清空。刷新按钮调用 `billing/getTodaySpend(true)
|
|
17
|
+
- **刷新保留旧值** —— 刷新在途时旧值留在屏幕上,刷新失败保留上一次有效值,不清空。刷新按钮调用 `billing/getTodaySpend(true)`,绕过宿主侧缓存;回合结束触发的重算与挂载/切换会话的读取走缓存路径。
|
|
18
18
|
|
|
19
19
|
## 模型体验
|
|
20
20
|
|
package/lib/client.js
CHANGED
|
@@ -7,7 +7,7 @@ window.__ModuleLoader__.load({
|
|
|
7
7
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
8
|
let react = require("react");
|
|
9
9
|
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
10
|
-
//#region
|
|
10
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
|
|
11
11
|
var _a$1;
|
|
12
12
|
function $constructor(name, initializer, params) {
|
|
13
13
|
function init(inst, def) {
|
|
@@ -66,7 +66,7 @@ window.__ModuleLoader__.load({
|
|
|
66
66
|
return globalConfig;
|
|
67
67
|
}
|
|
68
68
|
//#endregion
|
|
69
|
-
//#region
|
|
69
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
|
|
70
70
|
function getEnumValues(entries) {
|
|
71
71
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
72
72
|
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
@@ -82,7 +82,6 @@ window.__ModuleLoader__.load({
|
|
|
82
82
|
Object.defineProperty(this, "value", { value });
|
|
83
83
|
return value;
|
|
84
84
|
}
|
|
85
|
-
throw new Error("cached value already set");
|
|
86
85
|
} };
|
|
87
86
|
}
|
|
88
87
|
function nullish(input) {
|
|
@@ -128,7 +127,10 @@ window.__ModuleLoader__.load({
|
|
|
128
127
|
}
|
|
129
128
|
function mergeDefs(...defs) {
|
|
130
129
|
const mergedDescriptors = {};
|
|
131
|
-
for (const def of defs)
|
|
130
|
+
for (const def of defs) {
|
|
131
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
132
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
133
|
+
}
|
|
132
134
|
return Object.defineProperties({}, mergedDescriptors);
|
|
133
135
|
}
|
|
134
136
|
function esc(str) {
|
|
@@ -378,7 +380,7 @@ window.__ModuleLoader__.load({
|
|
|
378
380
|
return { ...iss };
|
|
379
381
|
}
|
|
380
382
|
//#endregion
|
|
381
|
-
//#region
|
|
383
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.js
|
|
382
384
|
const initializer$1 = (inst, def) => {
|
|
383
385
|
inst.name = "$ZodError";
|
|
384
386
|
Object.defineProperty(inst, "_zod", {
|
|
@@ -438,7 +440,7 @@ window.__ModuleLoader__.load({
|
|
|
438
440
|
return fieldErrors;
|
|
439
441
|
}
|
|
440
442
|
//#endregion
|
|
441
|
-
//#region
|
|
443
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/parse.js
|
|
442
444
|
const _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
443
445
|
const ctx = _ctx ? {
|
|
444
446
|
..._ctx,
|
|
@@ -552,7 +554,7 @@ window.__ModuleLoader__.load({
|
|
|
552
554
|
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
553
555
|
};
|
|
554
556
|
//#endregion
|
|
555
|
-
//#region
|
|
557
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/regexes.js
|
|
556
558
|
/**
|
|
557
559
|
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
|
558
560
|
* (timestamps embedded in the id). Use {@link cuid2} instead.
|
|
@@ -617,7 +619,7 @@ window.__ModuleLoader__.load({
|
|
|
617
619
|
const lowercase = /^[^A-Z]*$/;
|
|
618
620
|
const uppercase = /^[^a-z]*$/;
|
|
619
621
|
//#endregion
|
|
620
|
-
//#region
|
|
622
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/checks.js
|
|
621
623
|
const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
|
|
622
624
|
var _a;
|
|
623
625
|
inst._zod ?? (inst._zod = {});
|
|
@@ -635,8 +637,10 @@ window.__ModuleLoader__.load({
|
|
|
635
637
|
inst._zod.onattach.push((inst) => {
|
|
636
638
|
const bag = inst._zod.bag;
|
|
637
639
|
const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
638
|
-
if (def.value < curr)
|
|
639
|
-
|
|
640
|
+
if (def.value < curr) {
|
|
641
|
+
if (def.inclusive) bag.maximum = def.value;
|
|
642
|
+
else bag.exclusiveMaximum = def.value;
|
|
643
|
+
}
|
|
640
644
|
});
|
|
641
645
|
inst._zod.check = (payload) => {
|
|
642
646
|
if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
|
|
@@ -657,8 +661,10 @@ window.__ModuleLoader__.load({
|
|
|
657
661
|
inst._zod.onattach.push((inst) => {
|
|
658
662
|
const bag = inst._zod.bag;
|
|
659
663
|
const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
660
|
-
if (def.value > curr)
|
|
661
|
-
|
|
664
|
+
if (def.value > curr) {
|
|
665
|
+
if (def.inclusive) bag.minimum = def.value;
|
|
666
|
+
else bag.exclusiveMinimum = def.value;
|
|
667
|
+
}
|
|
662
668
|
});
|
|
663
669
|
inst._zod.check = (payload) => {
|
|
664
670
|
if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
|
|
@@ -975,7 +981,7 @@ window.__ModuleLoader__.load({
|
|
|
975
981
|
};
|
|
976
982
|
});
|
|
977
983
|
//#endregion
|
|
978
|
-
//#region
|
|
984
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/doc.js
|
|
979
985
|
var Doc = class {
|
|
980
986
|
constructor(args = []) {
|
|
981
987
|
this.content = [];
|
|
@@ -1006,14 +1012,14 @@ window.__ModuleLoader__.load({
|
|
|
1006
1012
|
}
|
|
1007
1013
|
};
|
|
1008
1014
|
//#endregion
|
|
1009
|
-
//#region
|
|
1015
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/versions.js
|
|
1010
1016
|
const version = {
|
|
1011
1017
|
major: 4,
|
|
1012
1018
|
minor: 4,
|
|
1013
1019
|
patch: 3
|
|
1014
1020
|
};
|
|
1015
1021
|
//#endregion
|
|
1016
|
-
//#region
|
|
1022
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/schemas.js
|
|
1017
1023
|
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
|
|
1018
1024
|
var _a;
|
|
1019
1025
|
inst ?? (inst = {});
|
|
@@ -1429,7 +1435,7 @@ window.__ModuleLoader__.load({
|
|
|
1429
1435
|
const $ZodUndefined = /*@__PURE__*/ $constructor("$ZodUndefined", (inst, def) => {
|
|
1430
1436
|
$ZodType.init(inst, def);
|
|
1431
1437
|
inst._zod.pattern = _undefined$2;
|
|
1432
|
-
inst._zod.values = new Set([void 0]);
|
|
1438
|
+
inst._zod.values = /* @__PURE__ */ new Set([void 0]);
|
|
1433
1439
|
inst._zod.parse = (payload, _ctx) => {
|
|
1434
1440
|
const input = payload.value;
|
|
1435
1441
|
if (typeof input === "undefined") return payload;
|
|
@@ -1950,7 +1956,7 @@ window.__ModuleLoader__.load({
|
|
|
1950
1956
|
inst._zod.optin = "optional";
|
|
1951
1957
|
inst._zod.optout = "optional";
|
|
1952
1958
|
defineLazy(inst._zod, "values", () => {
|
|
1953
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, void 0]) : void 0;
|
|
1959
|
+
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
|
|
1954
1960
|
});
|
|
1955
1961
|
defineLazy(inst._zod, "pattern", () => {
|
|
1956
1962
|
const pattern = def.innerType._zod.pattern;
|
|
@@ -1984,7 +1990,7 @@ window.__ModuleLoader__.load({
|
|
|
1984
1990
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
|
|
1985
1991
|
});
|
|
1986
1992
|
defineLazy(inst._zod, "values", () => {
|
|
1987
|
-
return def.innerType._zod.values ? new Set([...def.innerType._zod.values, null]) : void 0;
|
|
1993
|
+
return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
|
|
1988
1994
|
});
|
|
1989
1995
|
inst._zod.parse = (payload, ctx) => {
|
|
1990
1996
|
if (payload.value === null) return payload;
|
|
@@ -2150,7 +2156,7 @@ window.__ModuleLoader__.load({
|
|
|
2150
2156
|
}
|
|
2151
2157
|
}
|
|
2152
2158
|
//#endregion
|
|
2153
|
-
//#region
|
|
2159
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/registries.js
|
|
2154
2160
|
var _a;
|
|
2155
2161
|
var $ZodRegistry = class {
|
|
2156
2162
|
constructor() {
|
|
@@ -2197,7 +2203,7 @@ window.__ModuleLoader__.load({
|
|
|
2197
2203
|
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
|
|
2198
2204
|
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
2199
2205
|
//#endregion
|
|
2200
|
-
//#region
|
|
2206
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/api.js
|
|
2201
2207
|
// @__NO_SIDE_EFFECTS__
|
|
2202
2208
|
function _string(Class, params) {
|
|
2203
2209
|
return new Class({
|
|
@@ -2709,7 +2715,7 @@ window.__ModuleLoader__.load({
|
|
|
2709
2715
|
return ch;
|
|
2710
2716
|
}
|
|
2711
2717
|
//#endregion
|
|
2712
|
-
//#region
|
|
2718
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/to-json-schema.js
|
|
2713
2719
|
function initializeContext(params) {
|
|
2714
2720
|
let target = params?.target ?? "draft-2020-12";
|
|
2715
2721
|
if (target === "draft-4") target = "draft-04";
|
|
@@ -2925,8 +2931,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
2925
2931
|
defs[seen.defId] = seen.def;
|
|
2926
2932
|
}
|
|
2927
2933
|
}
|
|
2928
|
-
if (ctx.external) {} else if (Object.keys(defs).length > 0)
|
|
2929
|
-
|
|
2934
|
+
if (ctx.external) {} else if (Object.keys(defs).length > 0) {
|
|
2935
|
+
if (ctx.target === "draft-2020-12") result.$defs = defs;
|
|
2936
|
+
else result.definitions = defs;
|
|
2937
|
+
}
|
|
2930
2938
|
try {
|
|
2931
2939
|
const finalized = JSON.parse(JSON.stringify(result));
|
|
2932
2940
|
Object.defineProperty(finalized, "~standard", {
|
|
@@ -3002,7 +3010,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
3002
3010
|
return finalize(ctx, schema);
|
|
3003
3011
|
};
|
|
3004
3012
|
//#endregion
|
|
3005
|
-
//#region
|
|
3013
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/json-schema-processors.js
|
|
3006
3014
|
const formatMap = {
|
|
3007
3015
|
guid: "uuid",
|
|
3008
3016
|
url: "uri",
|
|
@@ -3039,16 +3047,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
3039
3047
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
3040
3048
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
3041
3049
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
3042
|
-
if (exMin)
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
if (
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3050
|
+
if (exMin) {
|
|
3051
|
+
if (legacy) {
|
|
3052
|
+
json.minimum = exclusiveMinimum;
|
|
3053
|
+
json.exclusiveMinimum = true;
|
|
3054
|
+
} else json.exclusiveMinimum = exclusiveMinimum;
|
|
3055
|
+
} else if (typeof minimum === "number") json.minimum = minimum;
|
|
3056
|
+
if (exMax) {
|
|
3057
|
+
if (legacy) {
|
|
3058
|
+
json.maximum = exclusiveMaximum;
|
|
3059
|
+
json.exclusiveMaximum = true;
|
|
3060
|
+
} else json.exclusiveMaximum = exclusiveMaximum;
|
|
3061
|
+
} else if (typeof maximum === "number") json.maximum = maximum;
|
|
3052
3062
|
if (typeof multipleOf === "number") json.multipleOf = multipleOf;
|
|
3053
3063
|
};
|
|
3054
3064
|
const booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
@@ -3072,9 +3082,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
3072
3082
|
const vals = [];
|
|
3073
3083
|
for (const val of def.values) if (val === void 0) {
|
|
3074
3084
|
if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
3075
|
-
} else if (typeof val === "bigint")
|
|
3076
|
-
|
|
3077
|
-
|
|
3085
|
+
} else if (typeof val === "bigint") {
|
|
3086
|
+
if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
3087
|
+
else vals.push(Number(val));
|
|
3088
|
+
} else vals.push(val);
|
|
3078
3089
|
if (vals.length === 0) {} else if (vals.length === 1) {
|
|
3079
3090
|
const val = vals[0];
|
|
3080
3091
|
json.type = val === null ? "null" : typeof val;
|
|
@@ -3234,7 +3245,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
3234
3245
|
seen.ref = def.innerType;
|
|
3235
3246
|
};
|
|
3236
3247
|
//#endregion
|
|
3237
|
-
//#region
|
|
3248
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/iso.js
|
|
3238
3249
|
const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
|
|
3239
3250
|
$ZodISODateTime.init(inst, def);
|
|
3240
3251
|
ZodStringFormat.init(inst, def);
|
|
@@ -3264,7 +3275,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
3264
3275
|
return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
|
|
3265
3276
|
}
|
|
3266
3277
|
//#endregion
|
|
3267
|
-
//#region
|
|
3278
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/errors.js
|
|
3268
3279
|
const initializer = (inst, issues) => {
|
|
3269
3280
|
$ZodError.init(inst, issues);
|
|
3270
3281
|
inst.name = "ZodError";
|
|
@@ -3286,7 +3297,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
3286
3297
|
};
|
|
3287
3298
|
const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, { Parent: Error });
|
|
3288
3299
|
//#endregion
|
|
3289
|
-
//#region
|
|
3300
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/parse.js
|
|
3290
3301
|
const parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
3291
3302
|
const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
3292
3303
|
const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
@@ -3300,7 +3311,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
3300
3311
|
const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
3301
3312
|
const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
3302
3313
|
//#endregion
|
|
3303
|
-
//#region
|
|
3314
|
+
//#region ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/schemas.js
|
|
3304
3315
|
const _installedGroups = /* @__PURE__ */ new WeakMap();
|
|
3305
3316
|
function _installLazyMethods(inst, group, methods) {
|
|
3306
3317
|
const proto = Object.getPrototypeOf(inst);
|
|
@@ -3829,11 +3840,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
3829
3840
|
});
|
|
3830
3841
|
});
|
|
3831
3842
|
function object(shape, params) {
|
|
3832
|
-
|
|
3843
|
+
const def = {
|
|
3833
3844
|
type: "object",
|
|
3834
3845
|
shape: shape ?? {},
|
|
3835
3846
|
...normalizeParams(params)
|
|
3836
|
-
}
|
|
3847
|
+
};
|
|
3848
|
+
return new ZodObject(def);
|
|
3837
3849
|
}
|
|
3838
3850
|
const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
|
|
3839
3851
|
$ZodUnion.init(inst, def);
|
|
@@ -3891,9 +3903,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
3891
3903
|
};
|
|
3892
3904
|
});
|
|
3893
3905
|
function _enum(values, params) {
|
|
3906
|
+
const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
3894
3907
|
return new ZodEnum({
|
|
3895
3908
|
type: "enum",
|
|
3896
|
-
entries
|
|
3909
|
+
entries,
|
|
3897
3910
|
...normalizeParams(params)
|
|
3898
3911
|
});
|
|
3899
3912
|
}
|
|
@@ -4080,7 +4093,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4080
4093
|
return /* @__PURE__ */ _superRefine(fn, params);
|
|
4081
4094
|
}
|
|
4082
4095
|
//#endregion
|
|
4083
|
-
//#region
|
|
4096
|
+
//#region ../llm-billing/lib/typert.remote-client.js
|
|
4084
4097
|
const _rayadesu_dsh_llm_billing_billing_getBalance_result$schema = object({
|
|
4085
4098
|
"isAvailable": boolean(),
|
|
4086
4099
|
"lines": array(object({
|
|
@@ -4144,7 +4157,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4144
4157
|
schema: _rayadesu_dsh_llm_billing_billing_getBalance_result$schema
|
|
4145
4158
|
},
|
|
4146
4159
|
sourceLocation: {
|
|
4147
|
-
"file": "packages/llm
|
|
4160
|
+
"file": "packages/llm-billing/src/balance.ts",
|
|
4148
4161
|
"line": 143,
|
|
4149
4162
|
"column": 3
|
|
4150
4163
|
}
|
|
@@ -4161,7 +4174,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4161
4174
|
source: "json",
|
|
4162
4175
|
codec: {
|
|
4163
4176
|
mode: "strict",
|
|
4164
|
-
typeSymbol: "@
|
|
4177
|
+
typeSymbol: "@rayadesu/dsh-llm-billing#billing/getSessionSpend:sessionId",
|
|
4165
4178
|
schema: _rayadesu_dsh_llm_billing_billing_getSessionSpend_parameter_0$schema
|
|
4166
4179
|
}
|
|
4167
4180
|
}],
|
|
@@ -4171,7 +4184,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4171
4184
|
schema: _rayadesu_dsh_llm_billing_billing_getSessionSpend_result$schema
|
|
4172
4185
|
},
|
|
4173
4186
|
sourceLocation: {
|
|
4174
|
-
"file": "packages/llm
|
|
4187
|
+
"file": "packages/llm-billing/src/balance.ts",
|
|
4175
4188
|
"line": 154,
|
|
4176
4189
|
"column": 3
|
|
4177
4190
|
}
|
|
@@ -4199,7 +4212,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4199
4212
|
schema: _rayadesu_dsh_llm_billing_billing_getTodaySpend_result$schema
|
|
4200
4213
|
},
|
|
4201
4214
|
sourceLocation: {
|
|
4202
|
-
"file": "packages/llm
|
|
4215
|
+
"file": "packages/llm-billing/src/balance.ts",
|
|
4203
4216
|
"line": 167,
|
|
4204
4217
|
"column": 3
|
|
4205
4218
|
}
|
|
@@ -4207,8 +4220,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4207
4220
|
]
|
|
4208
4221
|
};
|
|
4209
4222
|
//#endregion
|
|
4210
|
-
//#region \0dsh-css:C:\Users\admin\Desktop\me\code\
|
|
4211
|
-
const css = ".
|
|
4223
|
+
//#region \0dsh-css:C:\Users\admin\Desktop\me\code\DeepSeek-Harness-chat-billing\packages\ui-billing\src\client\BalanceBadge.module.css.mjs
|
|
4224
|
+
const css = "._4_Wqcq_root{position:relative}._4_Wqcq_trigger{background:var(--dsw-alias-fill-l2);min-height:32px;color:var(--dsw-alias-label-secondary);cursor:pointer;border:0;border-radius:8px;align-items:center;gap:4px;padding:4px 8px;display:inline-flex}._4_Wqcq_trigger:hover,._4_Wqcq_trigger:focus-visible{color:var(--dsw-alias-label-primary)}._4_Wqcq_trigger svg{transition:transform .12s}._4_Wqcq_chevronOpen{transform:rotate(180deg)}._4_Wqcq_triggerLines{text-align:left;flex-direction:column;align-items:flex-start;gap:0;display:flex}._4_Wqcq_linePrimary{font-variant-numeric:tabular-nums;font-size:12px;line-height:16px}._4_Wqcq_lineSecondary{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;font-size:11px;line-height:15px}._4_Wqcq_unavailable{color:var(--dsw-alias-label-tertiary)}._4_Wqcq_inlineIcon{color:var(--dsw-alias-label-tertiary);flex:none}._4_Wqcq_spinning{color:var(--dsw-alias-label-tertiary);flex:none;animation:.8s linear infinite _4_Wqcq_spin}@keyframes _4_Wqcq_spin{to{transform:rotate(360deg)}}._4_Wqcq_panel{z-index:100;box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-specific-menu);width:336px;max-width:min(360px,100vw - 32px);box-shadow:var(--dsw-shadow-lv3);border-radius:12px;flex-direction:column;gap:2px;padding:6px;display:flex;position:absolute;top:calc(100% + 6px);right:0}._4_Wqcq_amountRow{border-radius:8px;justify-content:space-between;align-items:center;gap:8px;padding:6px 8px;display:flex}._4_Wqcq_amountLabel{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;font-size:13px;line-height:18px}._4_Wqcq_spendRow{border-top:1px solid var(--dsw-alias-border-l2);border-radius:0;justify-content:space-between;align-items:center;gap:8px;padding:6px 8px;display:flex}._4_Wqcq_costRow{align-items:center;padding:2px 8px 6px;display:flex}._4_Wqcq_costBreakdown{color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;font-size:11px;line-height:16px}._4_Wqcq_amountActions{align-items:center;gap:2px;display:inline-flex}._4_Wqcq_infoButton,._4_Wqcq_refreshButton{width:24px;height:24px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:0;border-radius:6px;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}._4_Wqcq_infoButton:hover,._4_Wqcq_infoButton:focus-visible,._4_Wqcq_refreshButton:hover,._4_Wqcq_refreshButton:focus-visible{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-fill-l2)}._4_Wqcq_modelRow{border-radius:8px;justify-content:space-between;align-items:baseline;gap:8px;padding:6px 8px;display:flex}._4_Wqcq_modelName{color:var(--dsw-alias-label-secondary);flex:none;font-size:12px;line-height:18px}._4_Wqcq_tasks{text-align:right;min-width:0;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;overflow-wrap:anywhere;font-size:12px;line-height:18px}";
|
|
4212
4225
|
const tagId = "@rayadesu/dsh-client-ui-billing/BalanceBadge.module.css";
|
|
4213
4226
|
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
4214
4227
|
const tag = document.createElement("style");
|
|
@@ -4218,28 +4231,28 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4218
4231
|
document.head.appendChild(tag);
|
|
4219
4232
|
}
|
|
4220
4233
|
var BalanceBadge_module_css_default = {
|
|
4221
|
-
"amountActions": "
|
|
4222
|
-
"amountLabel": "
|
|
4223
|
-
"amountRow": "
|
|
4224
|
-
"chevronOpen": "
|
|
4225
|
-
"costBreakdown": "
|
|
4226
|
-
"costRow": "
|
|
4227
|
-
"infoButton": "
|
|
4228
|
-
"inlineIcon": "
|
|
4229
|
-
"linePrimary": "
|
|
4230
|
-
"lineSecondary": "
|
|
4231
|
-
"modelName": "
|
|
4232
|
-
"modelRow": "
|
|
4233
|
-
"panel": "
|
|
4234
|
-
"refreshButton": "
|
|
4235
|
-
"root": "
|
|
4236
|
-
"spendRow": "
|
|
4237
|
-
"spin": "
|
|
4238
|
-
"spinning": "
|
|
4239
|
-
"tasks": "
|
|
4240
|
-
"trigger": "
|
|
4241
|
-
"triggerLines": "
|
|
4242
|
-
"unavailable": "
|
|
4234
|
+
"amountActions": "_4_Wqcq_amountActions",
|
|
4235
|
+
"amountLabel": "_4_Wqcq_amountLabel",
|
|
4236
|
+
"amountRow": "_4_Wqcq_amountRow",
|
|
4237
|
+
"chevronOpen": "_4_Wqcq_chevronOpen",
|
|
4238
|
+
"costBreakdown": "_4_Wqcq_costBreakdown",
|
|
4239
|
+
"costRow": "_4_Wqcq_costRow",
|
|
4240
|
+
"infoButton": "_4_Wqcq_infoButton",
|
|
4241
|
+
"inlineIcon": "_4_Wqcq_inlineIcon",
|
|
4242
|
+
"linePrimary": "_4_Wqcq_linePrimary",
|
|
4243
|
+
"lineSecondary": "_4_Wqcq_lineSecondary",
|
|
4244
|
+
"modelName": "_4_Wqcq_modelName",
|
|
4245
|
+
"modelRow": "_4_Wqcq_modelRow",
|
|
4246
|
+
"panel": "_4_Wqcq_panel",
|
|
4247
|
+
"refreshButton": "_4_Wqcq_refreshButton",
|
|
4248
|
+
"root": "_4_Wqcq_root",
|
|
4249
|
+
"spendRow": "_4_Wqcq_spendRow",
|
|
4250
|
+
"spin": "_4_Wqcq_spin",
|
|
4251
|
+
"spinning": "_4_Wqcq_spinning",
|
|
4252
|
+
"tasks": "_4_Wqcq_tasks",
|
|
4253
|
+
"trigger": "_4_Wqcq_trigger",
|
|
4254
|
+
"triggerLines": "_4_Wqcq_triggerLines",
|
|
4255
|
+
"unavailable": "_4_Wqcq_unavailable"
|
|
4243
4256
|
};
|
|
4244
4257
|
//#endregion
|
|
4245
4258
|
//#region lib/types/client/BalanceBadge.js
|
|
@@ -4271,10 +4284,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4271
4284
|
* every session, a refresh action, and a spend disclaimer. Refreshing keeps
|
|
4272
4285
|
* the last values visible rather than blanking them.
|
|
4273
4286
|
*
|
|
4274
|
-
* The spend follows the conversation: a
|
|
4275
|
-
* recomputes only the (local, network-free)
|
|
4276
|
-
* through `getSessionSpend` /
|
|
4277
|
-
* manual-refresh snapshot and is never
|
|
4287
|
+
* The spend follows the conversation: when a prompt turn settles in the
|
|
4288
|
+
* current session, the badge recomputes only the (local, network-free)
|
|
4289
|
+
* session spend and today's spend through `getSessionSpend` /
|
|
4290
|
+
* `getTodaySpend`; the balance stays a manual-refresh snapshot and is never
|
|
4291
|
+
* refetched on its own.
|
|
4278
4292
|
* @param props - Remote face, locale, and the standard session-header runtime share.
|
|
4279
4293
|
* @returns the badge, or null until the first balance fetch settles.
|
|
4280
4294
|
*/
|
|
@@ -4287,8 +4301,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4287
4301
|
const [open, setOpen] = (0, react.useState)(false);
|
|
4288
4302
|
const [request, setRequest] = (0, react.useState)(0);
|
|
4289
4303
|
const rootRef = (0, react.useRef)(null);
|
|
4290
|
-
const
|
|
4291
|
-
const
|
|
4304
|
+
const running = useSession((snapshot) => snapshot.running);
|
|
4305
|
+
const pricedRunningRef = (0, react.useRef)(running);
|
|
4292
4306
|
(0, react.useEffect)(() => {
|
|
4293
4307
|
let current = true;
|
|
4294
4308
|
setRefreshing(balance !== null);
|
|
@@ -4328,8 +4342,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4328
4342
|
request
|
|
4329
4343
|
]);
|
|
4330
4344
|
(0, react.useEffect)(() => {
|
|
4331
|
-
if (
|
|
4332
|
-
|
|
4345
|
+
if (running === pricedRunningRef.current) return;
|
|
4346
|
+
pricedRunningRef.current = running;
|
|
4347
|
+
if (running) return;
|
|
4333
4348
|
let current = true;
|
|
4334
4349
|
const timer = setTimeout(() => {
|
|
4335
4350
|
Promise.resolve().then(() => {
|
|
@@ -4351,7 +4366,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
4351
4366
|
getSessionSpend,
|
|
4352
4367
|
getTodaySpend,
|
|
4353
4368
|
sessionId,
|
|
4354
|
-
|
|
4369
|
+
running
|
|
4355
4370
|
]);
|
|
4356
4371
|
(0, react.useEffect)(() => {
|
|
4357
4372
|
if (!open) return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Session-header billing badge: balance plus the current conversation's billed spend. */
|
|
2
2
|
import type { DeepSeekBalance, DeepSeekSessionSpend, DeepSeekTodaySpend } from '@rayadesu/dsh-llm-billing/types';
|
|
3
|
-
import type { SessionId } from '@deepseek-ai/dsh-
|
|
3
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
4
4
|
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
|
|
5
5
|
import { NS } from './locales.ts';
|
|
6
6
|
/** Registration-side Remote face used by the header badge. */
|
|
@@ -12,7 +12,7 @@ export interface BalanceBadgeInjected {
|
|
|
12
12
|
/**
|
|
13
13
|
* Read today's billed spend across every session; rejects with the Remote
|
|
14
14
|
* error message. `force` bypasses the host-side cache — the manual refresh
|
|
15
|
-
* passes it, the
|
|
15
|
+
* passes it, the turn-triggered recompute does not.
|
|
16
16
|
*/
|
|
17
17
|
getTodaySpend: (force?: boolean) => Promise<DeepSeekTodaySpend>;
|
|
18
18
|
}
|
|
@@ -26,10 +26,11 @@ export type BalanceBadgeProps = PropsRuntime<'conversation.session.header.utilit
|
|
|
26
26
|
* every session, a refresh action, and a spend disclaimer. Refreshing keeps
|
|
27
27
|
* the last values visible rather than blanking them.
|
|
28
28
|
*
|
|
29
|
-
* The spend follows the conversation: a
|
|
30
|
-
* recomputes only the (local, network-free)
|
|
31
|
-
* through `getSessionSpend` /
|
|
32
|
-
* manual-refresh snapshot and is never
|
|
29
|
+
* The spend follows the conversation: when a prompt turn settles in the
|
|
30
|
+
* current session, the badge recomputes only the (local, network-free)
|
|
31
|
+
* session spend and today's spend through `getSessionSpend` /
|
|
32
|
+
* `getTodaySpend`; the balance stays a manual-refresh snapshot and is never
|
|
33
|
+
* refetched on its own.
|
|
33
34
|
* @param props - Remote face, locale, and the standard session-header runtime share.
|
|
34
35
|
* @returns the badge, or null until the first balance fetch settles.
|
|
35
36
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** DeepSeek account-balance badge, browser half: one session-header utility entry. */
|
|
2
|
-
import type { ClientContext } from '@deepseek-ai/
|
|
2
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
3
3
|
import { type BillingKey } from './locales.ts';
|
|
4
4
|
export type { BalanceBadgeInjected, BalanceBadgeProps } from './BalanceBadge.tsx';
|
|
5
5
|
export type { BillingKey } from './locales.ts';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rayadesu/dsh-client-ui-billing",
|
|
3
3
|
"description": "Session-header DeepSeek account-balance and conversation-spend badge over the billing Remote",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/types/index.d.ts",
|
|
@@ -24,16 +24,18 @@
|
|
|
24
24
|
"dsh": {
|
|
25
25
|
"client": {
|
|
26
26
|
"inject": [
|
|
27
|
+
"@deepseek-ai/dsh-api-remotes",
|
|
27
28
|
"@deepseek-ai/dsh-client-locale",
|
|
28
|
-
"@deepseek-ai/dsh-client-
|
|
29
|
-
"@deepseek-ai/dsh-client-ui-
|
|
29
|
+
"@deepseek-ai/dsh-client-ui-conversation",
|
|
30
|
+
"@deepseek-ai/dsh-client-ui-renderer"
|
|
30
31
|
],
|
|
31
32
|
"platform": "web"
|
|
32
33
|
}
|
|
33
34
|
},
|
|
34
35
|
"scripts": {
|
|
35
36
|
"bundle": "tsdown",
|
|
36
|
-
"watch": "tsdown --watch"
|
|
37
|
+
"watch": "tsdown --watch",
|
|
38
|
+
"prepublishOnly": "node ../../scripts/verify-packages.mjs"
|
|
37
39
|
},
|
|
38
40
|
"license": "MIT",
|
|
39
41
|
"repository": {
|
|
@@ -45,27 +47,36 @@
|
|
|
45
47
|
"access": "public"
|
|
46
48
|
},
|
|
47
49
|
"peerDependencies": {
|
|
48
|
-
"@rayadesu/dsh-llm-billing": "^0.2.
|
|
49
|
-
"@deepseek-ai/dsh-client-locale": "^0.1.
|
|
50
|
-
"@deepseek-ai/dsh-client-
|
|
51
|
-
"@deepseek-ai/dsh-
|
|
52
|
-
"@deepseek-ai/dsh-
|
|
53
|
-
"@deepseek-ai/
|
|
54
|
-
"@deepseek-ai/
|
|
50
|
+
"@rayadesu/dsh-llm-billing": "^0.2.2",
|
|
51
|
+
"@deepseek-ai/dsh-client-locale": "^0.1.1-rc.2",
|
|
52
|
+
"@deepseek-ai/dsh-client-ui-conversation": "^0.1.1-rc.2",
|
|
53
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.1.1-rc.2",
|
|
54
|
+
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
55
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
56
|
+
"@deepseek-ai/dsh-api-remotes": "^0.1.1-rc.2",
|
|
57
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.1.1-rc.2",
|
|
58
|
+
"@deepseek-ai/dsh-session": "^0.1.1-rc.2"
|
|
55
59
|
},
|
|
56
60
|
"devDependencies": {
|
|
57
|
-
"@rayadesu/dsh-llm-billing": "^0.2.
|
|
58
|
-
"@deepseek-ai/dsh-client-locale": "^0.1.
|
|
59
|
-
"@deepseek-ai/dsh-client-runtime": "^0.1.
|
|
60
|
-
"@deepseek-ai/dsh-client-test-runtime": "^0.1.
|
|
61
|
-
"@deepseek-ai/dsh-client-ui-conversation": "^0.1.
|
|
62
|
-
"@deepseek-ai/dsh-client-ui-primitives": "^0.1.
|
|
63
|
-
"@deepseek-ai/dsh-client-ui-slots": "^0.1.
|
|
64
|
-
"@deepseek-ai/dsh-typert-protocol": "^0.1.
|
|
65
|
-
"@deepseek-ai/dsh-invariants": "^0.1.
|
|
61
|
+
"@rayadesu/dsh-llm-billing": "^0.2.2",
|
|
62
|
+
"@deepseek-ai/dsh-client-locale": "^0.1.1-rc.2",
|
|
63
|
+
"@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.2",
|
|
64
|
+
"@deepseek-ai/dsh-client-test-runtime": "^0.1.1-rc.2",
|
|
65
|
+
"@deepseek-ai/dsh-client-ui-conversation": "^0.1.1-rc.2",
|
|
66
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.1.1-rc.2",
|
|
67
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.1-rc.2",
|
|
68
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.1.1-rc.2",
|
|
69
|
+
"@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
|
|
70
|
+
"@testing-library/dom": "^10.4.1",
|
|
71
|
+
"@testing-library/react": "^16.3.2",
|
|
66
72
|
"@types/react": "~18.3.1",
|
|
67
73
|
"react": "^18.2.0",
|
|
68
|
-
"
|
|
74
|
+
"react-dom": "^18.2.0",
|
|
75
|
+
"use-sync-external-store": "^1.2.0",
|
|
76
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
77
|
+
"@deepseek-ai/dsh-api-remotes": "^0.1.1-rc.2",
|
|
78
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.1.1-rc.2",
|
|
79
|
+
"@deepseek-ai/dsh-session": "^0.1.1-rc.2"
|
|
69
80
|
},
|
|
70
81
|
"files": [
|
|
71
82
|
"lib/index.js",
|