@alexpeng/dsh-custom-plugin 0.1.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/LICENSE +201 -0
- package/README.i18n.yaml +7 -0
- package/README.md +146 -0
- package/README.zh.md +146 -0
- package/cordis.patch.yml +13 -0
- package/lib/client.js +4570 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +6252 -0
- package/lib/types/client/api.d.ts +85 -0
- package/lib/types/client/custom.d.ts +44 -0
- package/lib/types/client/index.d.ts +25 -0
- package/lib/types/client/mermaid-url.d.ts +14 -0
- package/lib/types/client/styles.d.ts +7 -0
- package/lib/types/credentials.d.ts +18 -0
- package/lib/types/dsh-home.d.ts +15 -0
- package/lib/types/extract.d.ts +54 -0
- package/lib/types/host-service.d.ts +130 -0
- package/lib/types/index.d.ts +15 -0
- package/lib/types/loopback.d.ts +22 -0
- package/lib/types/mount-once.d.ts +23 -0
- package/lib/types/protocol.d.ts +111 -0
- package/lib/types/routes.d.ts +13 -0
- package/lib/types/state.d.ts +22 -0
- package/lib/types/usage.d.ts +30 -0
- package/package.json +79 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date helpers and aggregation for the token-usage ledger.
|
|
3
|
+
* @module @alexpeng/dsh-custom-plugin/usage
|
|
4
|
+
*/
|
|
5
|
+
import type { SessionEvent } from '@deepseek-ai/dsh-session';
|
|
6
|
+
import type { UsageRow } from './protocol.ts';
|
|
7
|
+
/** One adapter-reported token accounting record (counters are disjoint). */
|
|
8
|
+
export interface UsageRecord {
|
|
9
|
+
inputTokens?: number;
|
|
10
|
+
outputTokens?: number;
|
|
11
|
+
cacheReadTokens?: number;
|
|
12
|
+
cacheWriteTokens?: number;
|
|
13
|
+
reasoningTokens?: number;
|
|
14
|
+
}
|
|
15
|
+
/** Local-timezone day key `YYYY-MM-DD`. */
|
|
16
|
+
export declare function dayKey(time?: number): string;
|
|
17
|
+
/** DeepSeek peak billing window: 09:00-12:00 / 14:00-18:00, off-peak is the
|
|
18
|
+
* remainder at half price. Approximated on the host-local clock — the ledger
|
|
19
|
+
* day key already uses the same clock. */
|
|
20
|
+
export declare function isPeakHour(time: number): boolean;
|
|
21
|
+
/** Fold one usage record into a ledger row, tracking the peak-hour portion. */
|
|
22
|
+
export declare function foldUsageRecord(row: UsageRow, usage: UsageRecord, peak: boolean): void;
|
|
23
|
+
/** Merge one aggregated row into a target row (scan folds per-session rows). */
|
|
24
|
+
export declare function mergeUsageRow(target: UsageRow, source: UsageRow): void;
|
|
25
|
+
/** Replay a session log and aggregate one day's per-model usage rows.
|
|
26
|
+
* `request/context` events anywhere in the log keep the model tracking in
|
|
27
|
+
* order; only `assistant/message` usage events whose own timestamp falls on
|
|
28
|
+
* `day` are folded, so a session crossing midnight contributes exactly the
|
|
29
|
+
* events it produced that day. */
|
|
30
|
+
export declare function aggregateDayUsage(events: readonly SessionEvent[], day: string): Record<string, UsageRow>;
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alexpeng/dsh-custom-plugin",
|
|
3
|
+
"description": "Custom convenience suite for the dsh web GUI: background colors with weather FX, liquid glass, a per-user-message timeline rail with stars and branching, multi-level project folders, prompt library, conversation export (JSON / Markdown / PDF-with-images), Mermaid rendering, quote reply, DeepSeek balance and daily token usage; dual-face plugin mounted without dsh source changes.",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"default": "./lib/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./client": {
|
|
14
|
+
"types": "./lib/types/client/index.d.ts",
|
|
15
|
+
"default": "./lib/client.js"
|
|
16
|
+
},
|
|
17
|
+
"./src/*": "./src/*",
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"dsh": {
|
|
21
|
+
"bundle": {
|
|
22
|
+
"patch": "./cordis.patch.yml"
|
|
23
|
+
},
|
|
24
|
+
"client": {
|
|
25
|
+
"inject": [
|
|
26
|
+
"@deepseek-ai/dsh-client-runtime"
|
|
27
|
+
],
|
|
28
|
+
"platform": "web"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc -p tsconfig.build.json && tsdown",
|
|
36
|
+
"bundle": "tsdown",
|
|
37
|
+
"watch": "tsdown --watch",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"test:watch": "vitest"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@deepseek-ai/cordis": "^4.0.1"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
48
|
+
"@deepseek-ai/dsh-attachment": "^0.1.1-rc.1",
|
|
49
|
+
"@deepseek-ai/dsh-client-locale": "^0.1.1-rc.1",
|
|
50
|
+
"@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.1",
|
|
51
|
+
"@deepseek-ai/dsh-client-ui-conversation": "^0.1.1-rc.1",
|
|
52
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.1-rc.1",
|
|
53
|
+
"@deepseek-ai/dsh-client-ui-theme": "^0.1.1-rc.1",
|
|
54
|
+
"@deepseek-ai/dsh-host-webserver": "^0.1.1-rc.1",
|
|
55
|
+
"@deepseek-ai/dsh-llm": "^0.1.1-rc.1",
|
|
56
|
+
"@deepseek-ai/dsh-session": "^0.1.1-rc.1",
|
|
57
|
+
"@deepseek-ai/dsh-session-query": "^0.1.1-rc.1",
|
|
58
|
+
"@deepseek-ai/dsh-settings": "^0.1.1-rc.1",
|
|
59
|
+
"@deepseek-ai/dsh-system-prompt": "^0.1.1-rc.1",
|
|
60
|
+
"@deepseek-ai/dsh-tools": "^0.1.1-rc.1",
|
|
61
|
+
"@types/node": "^22.20.0",
|
|
62
|
+
"@types/react": "~18.3.1",
|
|
63
|
+
"@types/react-dom": "^18.3.5",
|
|
64
|
+
"jsdom": "^25.0.0",
|
|
65
|
+
"react": "^18.3.1",
|
|
66
|
+
"react-dom": "^18.3.1",
|
|
67
|
+
"tsdown": "0.22.2",
|
|
68
|
+
"typescript": "~5.7.2",
|
|
69
|
+
"vitest": "^3.0.0"
|
|
70
|
+
},
|
|
71
|
+
"files": [
|
|
72
|
+
"lib",
|
|
73
|
+
"cordis.patch.yml",
|
|
74
|
+
"README.md",
|
|
75
|
+
"README.zh.md",
|
|
76
|
+
"README.i18n.yaml"
|
|
77
|
+
],
|
|
78
|
+
"license": "Apache-2.0"
|
|
79
|
+
}
|