dsh-message-actions 0.2.1 → 0.2.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/README.cn.md +83 -44
- package/README.md +84 -45
- package/icon.svg +4 -4
- package/lib/client.js +1973 -248
- package/lib/index.js +445 -55
- package/lib/shared.cjs +618 -31
- package/lib/store.cjs +13 -8
- package/locale/en.json +2 -2
- package/locale/zh.json +2 -2
- package/package.json +2 -2
package/lib/store.cjs
CHANGED
|
@@ -16,6 +16,8 @@ const os = require("node:os");
|
|
|
16
16
|
const path = require("node:path");
|
|
17
17
|
|
|
18
18
|
const STATE_VERSION = 1;
|
|
19
|
+
/** 默认预算 ¥5:首次运行、旧状态文件缺字段时都落到这里。 */
|
|
20
|
+
const DEFAULT_BUDGET_CENTS = 500;
|
|
19
21
|
const FILE_NAME = "cost-state.json";
|
|
20
22
|
const DIR_NAME = "dsh-message-actions";
|
|
21
23
|
/** 状态文件读取上限:正常只有几 KB,超限视为异常文件,不再解析。 */
|
|
@@ -55,10 +57,11 @@ function defaultState() {
|
|
|
55
57
|
lastRouting: null,
|
|
56
58
|
observedSpendTotalCents: 0,
|
|
57
59
|
dailySpendCents: {},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
settledSpendTotalCents: 0,
|
|
61
|
+
settledSinceObserveCents: 0,
|
|
62
|
+
lastSettledKey: "",
|
|
63
|
+
/** 会话统计的预算(分,人民币);0 表示未启用预算比例。 */
|
|
64
|
+
budgetCents: DEFAULT_BUDGET_CENTS,
|
|
62
65
|
updatedAt: 0
|
|
63
66
|
};
|
|
64
67
|
}
|
|
@@ -99,10 +102,11 @@ function normalizeCostState(raw) {
|
|
|
99
102
|
lastRouting: typeof raw.lastRouting === "string" ? raw.lastRouting : null,
|
|
100
103
|
observedSpendTotalCents: intOr(raw.observedSpendTotalCents, 0),
|
|
101
104
|
dailySpendCents: daily,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
105
|
+
settledSpendTotalCents: intOr(raw.settledSpendTotalCents, 0),
|
|
106
|
+
settledSinceObserveCents: Math.max(0, intOr(raw.settledSinceObserveCents, 0)),
|
|
107
|
+
lastSettledKey: typeof raw.lastSettledKey === "string" ? raw.lastSettledKey : "",
|
|
108
|
+
// 旧状态文件没有该字段:按默认预算补齐,不视为损坏。
|
|
109
|
+
budgetCents: Math.max(0, intOr(raw.budgetCents, DEFAULT_BUDGET_CENTS)),
|
|
106
110
|
updatedAt: intOr(raw.updatedAt, 0)
|
|
107
111
|
};
|
|
108
112
|
return { state, readOnly };
|
|
@@ -249,6 +253,7 @@ function persistCostState(filePath, state, readOnly, logger) {
|
|
|
249
253
|
|
|
250
254
|
module.exports = {
|
|
251
255
|
STATE_VERSION,
|
|
256
|
+
DEFAULT_BUDGET_CENTS,
|
|
252
257
|
MAX_STATE_BYTES,
|
|
253
258
|
expandHome,
|
|
254
259
|
resolveDshHome,
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
|
-
"title": "
|
|
4
|
-
"description": "
|
|
3
|
+
"title": "dsh-message-actions",
|
|
4
|
+
"description": "Completion sound; per-reply tokens, words, and cost; per-turn spend, stats panel, budget, and balance; recall, delete, and delete-to-end; multi-select share and export."
|
|
5
5
|
}
|
|
6
6
|
}
|
package/locale/zh.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-message-actions",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.3",
|
|
4
|
+
"description": "对话完成声音提示;每条回答的 token、字数与费用;单次花费、统计表、预算与余额;撤回、删除、删至末尾;多选分享与导出对话。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|