dsh-all-usage 1.1.18 → 1.2.0
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/CHANGELOG.md +453 -394
- package/LICENSE +21 -21
- package/README.en.md +270 -0
- package/README.md +142 -279
- package/assets/model-icons/ai2-color.svg +1 -0
- package/assets/model-icons/ai21-brand-color.svg +1 -0
- package/assets/model-icons/aionlabs.svg +1 -0
- package/assets/model-icons/alephalpha.svg +1 -0
- package/assets/model-icons/baai.svg +1 -0
- package/assets/model-icons/baichuan-color.svg +1 -0
- package/assets/model-icons/baidu-color.svg +1 -0
- package/assets/model-icons/bytedance-color.svg +1 -0
- package/assets/model-icons/cohere-color.svg +1 -0
- package/assets/model-icons/hunyuan-color.svg +1 -0
- package/assets/model-icons/ibm.svg +1 -0
- package/assets/model-icons/iflytekcloud-color.svg +1 -0
- package/assets/model-icons/internlm-color.svg +1 -0
- package/assets/model-icons/kling-color.svg +1 -0
- package/assets/model-icons/liquid.svg +1 -0
- package/assets/model-icons/longcat-color.svg +1 -0
- package/assets/model-icons/manifest.json +739 -213
- package/assets/model-icons/microsoft-color.svg +1 -0
- package/assets/model-icons/mistral-color.svg +1 -0
- package/assets/model-icons/nousresearch.svg +1 -0
- package/assets/model-icons/nova-color.svg +1 -0
- package/assets/model-icons/nvidia-color.svg +1 -0
- package/assets/model-icons/perplexity-color.svg +1 -0
- package/assets/model-icons/sensenova-color.svg +1 -0
- package/assets/model-icons/skywork-color.svg +1 -0
- package/assets/model-icons/snowflake-color.svg +1 -0
- package/assets/model-icons/stepfun-color.svg +1 -0
- package/assets/model-icons/tencent-color.svg +1 -0
- package/assets/model-icons/tii-color.svg +1 -0
- package/assets/model-icons/upstage-color.svg +1 -0
- package/assets/model-icons/voyage-color.svg +1 -0
- package/assets/model-icons/xiaomimimo.svg +1 -0
- package/assets/model-icons/yandex.svg +1 -0
- package/assets/readme-architecture-en.svg +95 -0
- package/assets/readme-architecture-zh.svg +95 -0
- package/assets/readme-sync-en.svg +81 -0
- package/assets/readme-sync-zh.svg +81 -0
- package/assets/screenshots/en/01-overview.png +0 -0
- package/assets/screenshots/en/02-heatmap.png +0 -0
- package/assets/screenshots/en/03-model-usage.png +0 -0
- package/assets/screenshots/en/04-request-logs.png +0 -0
- package/assets/screenshots/en/05-cost-settings.png +0 -0
- package/assets/screenshots/zh/01-overview.png +0 -0
- package/assets/screenshots/zh/02-heatmap.png +0 -0
- package/assets/screenshots/zh/03-model-usage.png +0 -0
- package/assets/screenshots/zh/04-request-logs.png +0 -0
- package/assets/screenshots/zh/05-cost-settings.png +0 -0
- package/cordis.patch.yml +5 -5
- package/lib/aggregation.js +1842 -1112
- package/lib/client.js +1 -1
- package/lib/http.js +417 -385
- package/lib/icons.js +40 -0
- package/lib/ledger.js +1000 -531
- package/lib/plugin.js +347 -327
- package/lib/pricing-runtime.js +615 -551
- package/lib/pricing.js +1463 -1412
- package/lib/records-cache.js +113 -0
- package/lib/session-sync.js +976 -841
- package/lib/usage-core.js +33 -10
- package/lib/version-check.js +133 -133
- package/package.json +7 -3
- package/screenshots.json +10 -3
- package/assets/screenshot-1.png +0 -0
- package/assets/screenshot-2.png +0 -0
- package/assets/screenshot-3.png +0 -0
package/lib/icons.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto'
|
|
2
|
+
import { readFile } from 'node:fs/promises'
|
|
3
|
+
|
|
4
|
+
// Brand marks are served on demand instead of being embedded in the client
|
|
5
|
+
// bundle: the page asks only for the icons it actually renders (and the browser
|
|
6
|
+
// caches them), so adding a brand costs nothing in the bundle. The manifest stays
|
|
7
|
+
// the single source of truth - it is what the build validates and what this reads.
|
|
8
|
+
const ICONS_URL = new URL('../assets/model-icons/', import.meta.url)
|
|
9
|
+
let cache = null
|
|
10
|
+
|
|
11
|
+
async function loadIcons() {
|
|
12
|
+
if (cache !== null) return cache
|
|
13
|
+
const manifest = JSON.parse(await readFile(new URL('manifest.json', ICONS_URL), 'utf8'))
|
|
14
|
+
const entries = []
|
|
15
|
+
for (const icon of manifest.icons) {
|
|
16
|
+
if (icon === null || typeof icon !== 'object' || typeof icon.key !== 'string' || icon.key === '') continue
|
|
17
|
+
if (typeof icon.file !== 'string' || icon.file === '') continue
|
|
18
|
+
const svg = await readFile(new URL(icon.file, ICONS_URL), 'utf8')
|
|
19
|
+
const compact = svg.replace(/>\s+</g, '><').trim()
|
|
20
|
+
const body = Buffer.from(compact, 'utf8')
|
|
21
|
+
entries.push({
|
|
22
|
+
key: icon.key,
|
|
23
|
+
label: typeof icon.label === 'string' && icon.label !== '' ? icon.label : icon.key,
|
|
24
|
+
body,
|
|
25
|
+
etag: '"' + createHash('sha256').update(body).digest('base64url').slice(0, 16) + '"',
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
cache = { entries, byKey: new Map(entries.map((entry) => [entry.key, entry])) }
|
|
29
|
+
return cache
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** One icon by key, or null. Unknown keys never touch the filesystem. */
|
|
33
|
+
export async function findModelIcon(key) {
|
|
34
|
+
if (typeof key !== 'string' || key === '') return null
|
|
35
|
+
const { byKey } = await loadIcons()
|
|
36
|
+
return byKey.get(key) || null
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// listModelIcons() was removed: it had no caller. Tests and diagnostics read the
|
|
40
|
+
// manifest instead, and the icon route only needs findModelIcon().
|