@mzzsfy/dsh-usage-stats 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/package.json +2 -2
- package/src/client.js +1 -1
- package/src/index.js +2 -2
- package/test/client-id.test.mjs +16 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mzzsfy/dsh-usage-stats",
|
|
3
|
-
"description": "
|
|
4
|
-
"version": "0.2.
|
|
3
|
+
"description": "全会话 token 用量与费用统计:仪表盘(趋势/热力图/明细/CSV 导出)、输入区费用条、自定义模型价格,数据全部本地",
|
|
4
|
+
"version": "0.2.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"exports": {
|
package/src/client.js
CHANGED
package/src/index.js
CHANGED
|
@@ -53,8 +53,8 @@ const SETTINGS_SCHEMA = z.object({
|
|
|
53
53
|
model: z.string().description('模型 id,支持 provider/model 精确或模型名前缀'),
|
|
54
54
|
input: z.number().description('输入单价 / 百万 token'),
|
|
55
55
|
output: z.number().description('输出单价 / 百万 token'),
|
|
56
|
-
cacheRead: z.number().
|
|
57
|
-
currency: z.union([z.
|
|
56
|
+
cacheRead: z.number().description('缓存命中单价 / 百万 token'),
|
|
57
|
+
currency: z.union([z.const('CNY'), z.const('USD')]).default('USD').description('单价原生币种'),
|
|
58
58
|
})).default([]).description('自定义模型单价表,命中优先于目录价'),
|
|
59
59
|
})
|
|
60
60
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// client.js 注册 id 守卫:loader 按 graph row id(完整包名)匹配注册,短名即加载失败。
|
|
2
|
+
import { readFileSync } from 'node:fs'
|
|
3
|
+
import { dirname, join } from 'node:path'
|
|
4
|
+
import { fileURLToPath } from 'node:url'
|
|
5
|
+
import test from 'node:test'
|
|
6
|
+
import assert from 'node:assert/strict'
|
|
7
|
+
|
|
8
|
+
const PKG_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
|
|
9
|
+
const { name } = JSON.parse(readFileSync(join(PKG_ROOT, 'package.json'), 'utf8'))
|
|
10
|
+
|
|
11
|
+
test('client.js 注册 id 为完整包名', () => {
|
|
12
|
+
const source = readFileSync(join(PKG_ROOT, 'src', 'client.js'), 'utf8')
|
|
13
|
+
const match = source.match(/__ModuleLoader__\.load\(\{\s*id:\s*'([^']+)'/)
|
|
14
|
+
assert.ok(match, 'client.js 缺少 __ModuleLoader__.load 注册')
|
|
15
|
+
assert.equal(match[1], name)
|
|
16
|
+
})
|