dsh-all-usage 1.1.1 → 1.1.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/CHANGELOG.md +87 -0
- package/LICENSE +21 -21
- package/README.md +216 -27
- package/assets/screenshot-1.png +0 -0
- package/assets/screenshot-2.png +0 -0
- package/assets/screenshot-3.png +0 -0
- package/cordis.patch.yml +5 -5
- package/fixtures/usage-events.json +172 -0
- package/lib/aggregation.js +1002 -0
- package/lib/balance.js +112 -0
- package/lib/client.js +1 -2271
- package/lib/http.js +305 -0
- package/lib/index.js +2 -1572
- package/lib/ledger.js +464 -0
- package/lib/plugin.js +276 -0
- package/lib/pricing-runtime.js +282 -0
- package/lib/pricing.js +908 -0
- package/lib/session-sync.js +589 -0
- package/lib/usage-core.js +127 -0
- package/package.json +82 -56
- package/screenshots.json +1 -5
- package/scripts/replay-fixture.mjs +155 -0
- package/assets/screenshot-4.png +0 -0
- package/assets/screenshot-5.png +0 -0
- package/assets/screenshot-6.png +0 -0
- package/assets/screenshot-7.png +0 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"name": "redacted-usage-fixture",
|
|
4
|
+
"description": "Synthetic DSH session events covering a failed request, an orphan usage chunk, and a chunk replaced by a final message.",
|
|
5
|
+
"timezone": "UTC",
|
|
6
|
+
"query": { "start": "2024-01-01", "end": "2024-01-01", "utc": "1" },
|
|
7
|
+
"workspaces": [
|
|
8
|
+
{
|
|
9
|
+
"id": "workspace-example",
|
|
10
|
+
"path": "/redacted/example-workspace",
|
|
11
|
+
"title": "Example Workspace"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"sessions": [
|
|
15
|
+
{ "header": { "id": "session-failed", "cwd": "/redacted/example-workspace" } },
|
|
16
|
+
{ "header": { "id": "session-complete", "cwd": "/redacted/example-workspace" } },
|
|
17
|
+
{ "header": { "id": "session-orphan", "cwd": "/redacted/example-workspace" } }
|
|
18
|
+
],
|
|
19
|
+
"events": {
|
|
20
|
+
"session-failed": [
|
|
21
|
+
{
|
|
22
|
+
"seq": 1,
|
|
23
|
+
"time": 1704110400000,
|
|
24
|
+
"type": "request/context",
|
|
25
|
+
"data": { "provider": "deepseek", "model": "deepseek-chat" }
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"seq": 2,
|
|
29
|
+
"time": 1704110400000,
|
|
30
|
+
"type": "assistant/chunk",
|
|
31
|
+
"data": {
|
|
32
|
+
"turn": 1,
|
|
33
|
+
"step": 1,
|
|
34
|
+
"chunk": {
|
|
35
|
+
"type": "usage",
|
|
36
|
+
"usage": {
|
|
37
|
+
"inputTokens": 100,
|
|
38
|
+
"outputTokens": 20,
|
|
39
|
+
"cacheReadTokens": 50,
|
|
40
|
+
"cacheWriteTokens": 5,
|
|
41
|
+
"reasoningTokens": 7
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"seq": 3,
|
|
48
|
+
"time": 1704110400000,
|
|
49
|
+
"type": "request/error",
|
|
50
|
+
"data": { "code": "upstream-failed" }
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"session-complete": [
|
|
54
|
+
{
|
|
55
|
+
"seq": 1,
|
|
56
|
+
"time": 1704110400000,
|
|
57
|
+
"type": "request/context",
|
|
58
|
+
"data": { "provider": "deepseek", "model": "deepseek-chat" }
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"seq": 2,
|
|
62
|
+
"time": 1704110400000,
|
|
63
|
+
"type": "assistant/chunk",
|
|
64
|
+
"data": {
|
|
65
|
+
"turn": 1,
|
|
66
|
+
"step": 1,
|
|
67
|
+
"chunk": {
|
|
68
|
+
"type": "usage",
|
|
69
|
+
"usage": {
|
|
70
|
+
"inputTokens": 10,
|
|
71
|
+
"outputTokens": 15,
|
|
72
|
+
"cacheReadTokens": 3,
|
|
73
|
+
"cacheWriteTokens": 2,
|
|
74
|
+
"reasoningTokens": 1
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"seq": 3,
|
|
81
|
+
"time": 1704110400000,
|
|
82
|
+
"type": "assistant/message",
|
|
83
|
+
"data": {
|
|
84
|
+
"turn": 1,
|
|
85
|
+
"step": 1,
|
|
86
|
+
"message": { "source": { "provider": "deepseek", "model": "deepseek-chat" } },
|
|
87
|
+
"usage": {
|
|
88
|
+
"inputTokens": 12,
|
|
89
|
+
"outputTokens": 18,
|
|
90
|
+
"cacheReadTokens": 4,
|
|
91
|
+
"cacheWriteTokens": 2,
|
|
92
|
+
"reasoningTokens": 2
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"seq": 4,
|
|
98
|
+
"time": 1704110400000,
|
|
99
|
+
"type": "turn/end",
|
|
100
|
+
"data": { "turn": 1, "reason": { "kind": "completed" } }
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
"session-orphan": [
|
|
104
|
+
{
|
|
105
|
+
"seq": 1,
|
|
106
|
+
"time": 1704110400000,
|
|
107
|
+
"type": "assistant/chunk",
|
|
108
|
+
"data": {
|
|
109
|
+
"turn": 1,
|
|
110
|
+
"step": 1,
|
|
111
|
+
"chunk": {
|
|
112
|
+
"type": "usage",
|
|
113
|
+
"usage": {
|
|
114
|
+
"inputTokens": 7,
|
|
115
|
+
"outputTokens": 4,
|
|
116
|
+
"cacheReadTokens": 8,
|
|
117
|
+
"cacheWriteTokens": 1,
|
|
118
|
+
"reasoningTokens": 0
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
"expected": {
|
|
126
|
+
"totals": {
|
|
127
|
+
"turns": 1,
|
|
128
|
+
"sessions": 3,
|
|
129
|
+
"input": 119,
|
|
130
|
+
"output": 42,
|
|
131
|
+
"cacheRead": 62,
|
|
132
|
+
"cacheWrite": 8,
|
|
133
|
+
"reasoning": 9
|
|
134
|
+
},
|
|
135
|
+
"records": 3,
|
|
136
|
+
"models": [
|
|
137
|
+
{
|
|
138
|
+
"provider": "deepseek",
|
|
139
|
+
"requestedModel": "deepseek-chat",
|
|
140
|
+
"actualModel": null,
|
|
141
|
+
"calls": 1,
|
|
142
|
+
"input": 100,
|
|
143
|
+
"output": 20,
|
|
144
|
+
"cacheRead": 50,
|
|
145
|
+
"cacheWrite": 5,
|
|
146
|
+
"reasoning": 7
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"provider": "deepseek",
|
|
150
|
+
"requestedModel": "deepseek-chat",
|
|
151
|
+
"actualModel": "deepseek-chat",
|
|
152
|
+
"calls": 1,
|
|
153
|
+
"input": 12,
|
|
154
|
+
"output": 18,
|
|
155
|
+
"cacheRead": 4,
|
|
156
|
+
"cacheWrite": 2,
|
|
157
|
+
"reasoning": 2
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"provider": null,
|
|
161
|
+
"requestedModel": null,
|
|
162
|
+
"actualModel": null,
|
|
163
|
+
"calls": 1,
|
|
164
|
+
"input": 7,
|
|
165
|
+
"output": 4,
|
|
166
|
+
"cacheRead": 8,
|
|
167
|
+
"cacheWrite": 1,
|
|
168
|
+
"reasoning": 0
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
}
|