@rayadesu/dsh-llm-billing 0.3.12 → 0.3.13
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.i18n.yaml +2 -2
- package/README.md +17 -4
- package/README.zh.md +17 -4
- package/lib/index.js +302 -60
- package/lib/typert.host.js +79 -6
- package/lib/typert.remote-client.d.ts +3 -1
- package/lib/typert.remote-client.js +79 -6
- package/lib/types/balance.d.ts +22 -2
- package/lib/types/balance.js +19 -1
- package/lib/types/index.d.ts +2 -2
- package/lib/types/index.js +24 -5
- package/lib/types/today-spend.d.ts +192 -47
- package/lib/types/today-spend.js +270 -58
- package/lib/types/types.d.ts +50 -3
- package/package.json +20 -20
package/lib/typert.host.js
CHANGED
|
@@ -11,6 +11,26 @@ const _rayadesu_dsh_llm_billing_billing_getBalance_result$schema = z.object({
|
|
|
11
11
|
'toppedUp': z.string(),
|
|
12
12
|
})),
|
|
13
13
|
})
|
|
14
|
+
const _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_parameter_0$schema = z.intersection(z.string(), z.unknown())
|
|
15
|
+
const _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_parameter_1$schema = z.union([z.undefined(), z.literal(false), z.literal(true)])
|
|
16
|
+
const _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_result$schema = z.object({
|
|
17
|
+
'total': z.number(),
|
|
18
|
+
'models': z.array(z.object({
|
|
19
|
+
'model': z.string(),
|
|
20
|
+
'displayName': z.string(),
|
|
21
|
+
'cost': z.number(),
|
|
22
|
+
'peakCost': z.number(),
|
|
23
|
+
'offPeakCost': z.number(),
|
|
24
|
+
'cacheHitInputTokens': z.number(),
|
|
25
|
+
'cacheMissInputTokens': z.number(),
|
|
26
|
+
'outputTokens': z.number(),
|
|
27
|
+
'cacheHitInputCost': z.number(),
|
|
28
|
+
'cacheMissInputCost': z.number(),
|
|
29
|
+
'outputCost': z.number(),
|
|
30
|
+
})),
|
|
31
|
+
'isSubagent': z.boolean(),
|
|
32
|
+
'crossedDay': z.boolean(),
|
|
33
|
+
})
|
|
14
34
|
const _rayadesu_dsh_llm_billing_billing_getSessionSpend_parameter_0$schema = z.intersection(z.string(), z.unknown())
|
|
15
35
|
const _rayadesu_dsh_llm_billing_billing_getSessionSpend_result$schema = z.object({
|
|
16
36
|
'total': z.number(),
|
|
@@ -41,6 +61,7 @@ const _rayadesu_dsh_llm_billing_billing_getTodaySessionsSpend_result$schema = z.
|
|
|
41
61
|
'sessionId': z.intersection(z.string(), z.unknown()),
|
|
42
62
|
'title': z.union([z.literal(null), z.string()]),
|
|
43
63
|
'total': z.number(),
|
|
64
|
+
'ownTotal': z.number(),
|
|
44
65
|
})),
|
|
45
66
|
})
|
|
46
67
|
const _rayadesu_dsh_llm_billing_billing_getTodaySpend_parameter_0$schema = z.union([z.undefined(), z.literal(false), z.literal(true)])
|
|
@@ -88,6 +109,7 @@ export const TYPERT = {
|
|
|
88
109
|
mode: 'strict',
|
|
89
110
|
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getBalance:force',
|
|
90
111
|
schema: _rayadesu_dsh_llm_billing_billing_getBalance_parameter_0$schema,
|
|
112
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getBalance_parameter_0$schema,
|
|
91
113
|
},
|
|
92
114
|
},
|
|
93
115
|
],
|
|
@@ -95,8 +117,48 @@ export const TYPERT = {
|
|
|
95
117
|
mode: 'strict',
|
|
96
118
|
typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekBalance',
|
|
97
119
|
schema: _rayadesu_dsh_llm_billing_billing_getBalance_result$schema,
|
|
120
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getBalance_result$schema,
|
|
121
|
+
},
|
|
122
|
+
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":172,"column":3},
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: '@rayadesu/dsh-llm-billing#billing/getDelegatedSpend',
|
|
126
|
+
service: 'billing',
|
|
127
|
+
namespace: 'billing',
|
|
128
|
+
method: 'getDelegatedSpend',
|
|
129
|
+
invocation: { kind: 'direct' },
|
|
130
|
+
parameters: [
|
|
131
|
+
{
|
|
132
|
+
name: 'sessionId',
|
|
133
|
+
wire: 'sessionId',
|
|
134
|
+
source: 'json',
|
|
135
|
+
codec: {
|
|
136
|
+
mode: 'strict',
|
|
137
|
+
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getDelegatedSpend:sessionId',
|
|
138
|
+
schema: _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_parameter_0$schema,
|
|
139
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_parameter_0$schema,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'force',
|
|
144
|
+
wire: 'force',
|
|
145
|
+
source: 'json',
|
|
146
|
+
acceptsUndefined: true,
|
|
147
|
+
codec: {
|
|
148
|
+
mode: 'strict',
|
|
149
|
+
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getDelegatedSpend:force',
|
|
150
|
+
schema: _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_parameter_1$schema,
|
|
151
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_parameter_1$schema,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
result: {
|
|
156
|
+
mode: 'strict',
|
|
157
|
+
typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekDelegatedSpend',
|
|
158
|
+
schema: _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_result$schema,
|
|
159
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_result$schema,
|
|
98
160
|
},
|
|
99
|
-
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":
|
|
161
|
+
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":226,"column":3},
|
|
100
162
|
},
|
|
101
163
|
{
|
|
102
164
|
id: '@rayadesu/dsh-llm-billing#billing/getSessionSpend',
|
|
@@ -113,6 +175,7 @@ export const TYPERT = {
|
|
|
113
175
|
mode: 'strict',
|
|
114
176
|
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getSessionSpend:sessionId',
|
|
115
177
|
schema: _rayadesu_dsh_llm_billing_billing_getSessionSpend_parameter_0$schema,
|
|
178
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getSessionSpend_parameter_0$schema,
|
|
116
179
|
},
|
|
117
180
|
},
|
|
118
181
|
],
|
|
@@ -120,8 +183,9 @@ export const TYPERT = {
|
|
|
120
183
|
mode: 'strict',
|
|
121
184
|
typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekSessionSpend',
|
|
122
185
|
schema: _rayadesu_dsh_llm_billing_billing_getSessionSpend_result$schema,
|
|
186
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getSessionSpend_result$schema,
|
|
123
187
|
},
|
|
124
|
-
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":
|
|
188
|
+
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":183,"column":3},
|
|
125
189
|
},
|
|
126
190
|
{
|
|
127
191
|
id: '@rayadesu/dsh-llm-billing#billing/getSessionTurnSpends',
|
|
@@ -138,6 +202,7 @@ export const TYPERT = {
|
|
|
138
202
|
mode: 'strict',
|
|
139
203
|
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getSessionTurnSpends:sessionId',
|
|
140
204
|
schema: _rayadesu_dsh_llm_billing_billing_getSessionTurnSpends_parameter_0$schema,
|
|
205
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getSessionTurnSpends_parameter_0$schema,
|
|
141
206
|
},
|
|
142
207
|
},
|
|
143
208
|
],
|
|
@@ -145,8 +210,9 @@ export const TYPERT = {
|
|
|
145
210
|
mode: 'strict',
|
|
146
211
|
typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekSessionTurnSpends',
|
|
147
212
|
schema: _rayadesu_dsh_llm_billing_billing_getSessionTurnSpends_result$schema,
|
|
213
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getSessionTurnSpends_result$schema,
|
|
148
214
|
},
|
|
149
|
-
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":
|
|
215
|
+
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":251,"column":3},
|
|
150
216
|
},
|
|
151
217
|
{
|
|
152
218
|
id: '@rayadesu/dsh-llm-billing#billing/getTodaySessionsSpend',
|
|
@@ -164,6 +230,7 @@ export const TYPERT = {
|
|
|
164
230
|
mode: 'strict',
|
|
165
231
|
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getTodaySessionsSpend:force',
|
|
166
232
|
schema: _rayadesu_dsh_llm_billing_billing_getTodaySessionsSpend_parameter_0$schema,
|
|
233
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getTodaySessionsSpend_parameter_0$schema,
|
|
167
234
|
},
|
|
168
235
|
},
|
|
169
236
|
],
|
|
@@ -171,8 +238,9 @@ export const TYPERT = {
|
|
|
171
238
|
mode: 'strict',
|
|
172
239
|
typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekTodaySessionsSpend',
|
|
173
240
|
schema: _rayadesu_dsh_llm_billing_billing_getTodaySessionsSpend_result$schema,
|
|
241
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getTodaySessionsSpend_result$schema,
|
|
174
242
|
},
|
|
175
|
-
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":
|
|
243
|
+
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":211,"column":3},
|
|
176
244
|
},
|
|
177
245
|
{
|
|
178
246
|
id: '@rayadesu/dsh-llm-billing#billing/getTodaySpend',
|
|
@@ -190,6 +258,7 @@ export const TYPERT = {
|
|
|
190
258
|
mode: 'strict',
|
|
191
259
|
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getTodaySpend:force',
|
|
192
260
|
schema: _rayadesu_dsh_llm_billing_billing_getTodaySpend_parameter_0$schema,
|
|
261
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getTodaySpend_parameter_0$schema,
|
|
193
262
|
},
|
|
194
263
|
},
|
|
195
264
|
],
|
|
@@ -197,8 +266,9 @@ export const TYPERT = {
|
|
|
197
266
|
mode: 'strict',
|
|
198
267
|
typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekTodaySpend',
|
|
199
268
|
schema: _rayadesu_dsh_llm_billing_billing_getTodaySpend_result$schema,
|
|
269
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getTodaySpend_result$schema,
|
|
200
270
|
},
|
|
201
|
-
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":
|
|
271
|
+
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":196,"column":3},
|
|
202
272
|
},
|
|
203
273
|
{
|
|
204
274
|
id: '@rayadesu/dsh-llm-billing#billing/getTurnSpend',
|
|
@@ -215,6 +285,7 @@ export const TYPERT = {
|
|
|
215
285
|
mode: 'strict',
|
|
216
286
|
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getTurnSpend:sessionId',
|
|
217
287
|
schema: _rayadesu_dsh_llm_billing_billing_getTurnSpend_parameter_0$schema,
|
|
288
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getTurnSpend_parameter_0$schema,
|
|
218
289
|
},
|
|
219
290
|
},
|
|
220
291
|
{
|
|
@@ -225,6 +296,7 @@ export const TYPERT = {
|
|
|
225
296
|
mode: 'strict',
|
|
226
297
|
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getTurnSpend:messageId',
|
|
227
298
|
schema: _rayadesu_dsh_llm_billing_billing_getTurnSpend_parameter_1$schema,
|
|
299
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getTurnSpend_parameter_1$schema,
|
|
228
300
|
},
|
|
229
301
|
},
|
|
230
302
|
],
|
|
@@ -232,8 +304,9 @@ export const TYPERT = {
|
|
|
232
304
|
mode: 'strict',
|
|
233
305
|
typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekTurnSpend',
|
|
234
306
|
schema: _rayadesu_dsh_llm_billing_billing_getTurnSpend_result$schema,
|
|
307
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getTurnSpend_result$schema,
|
|
235
308
|
},
|
|
236
|
-
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":
|
|
309
|
+
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":239,"column":3},
|
|
237
310
|
},
|
|
238
311
|
],
|
|
239
312
|
model: {
|
|
@@ -3,11 +3,12 @@ import type {
|
|
|
3
3
|
RemoteResult,
|
|
4
4
|
TypertRemoteContribution,
|
|
5
5
|
} from '@deepseek-ai/dsh-typert-protocol'
|
|
6
|
-
import type { DeepSeekBalance, DeepSeekSessionSpend, DeepSeekSessionTurnSpends, DeepSeekTodaySessionsSpend, DeepSeekTodaySpend, DeepSeekTurnSpend } from '@rayadesu/dsh-llm-billing/types'
|
|
6
|
+
import type { DeepSeekBalance, DeepSeekDelegatedSpend, DeepSeekSessionSpend, DeepSeekSessionTurnSpends, DeepSeekTodaySessionsSpend, DeepSeekTodaySpend, DeepSeekTurnSpend } from '@rayadesu/dsh-llm-billing/types'
|
|
7
7
|
|
|
8
8
|
declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
9
9
|
interface TypertRemoteNamespace$62696c6c696e67 {
|
|
10
10
|
getBalance: (force?: boolean) => Promise<RemoteResult<DeepSeekBalance>>
|
|
11
|
+
getDelegatedSpend: (sessionId: SessionId, force?: boolean) => Promise<RemoteResult<DeepSeekDelegatedSpend>>
|
|
11
12
|
getSessionSpend: (sessionId: SessionId) => Promise<RemoteResult<DeepSeekSessionSpend>>
|
|
12
13
|
getSessionTurnSpends: (sessionId: SessionId) => Promise<RemoteResult<DeepSeekSessionTurnSpends>>
|
|
13
14
|
getTodaySessionsSpend: (force?: boolean) => Promise<RemoteResult<DeepSeekTodaySessionsSpend>>
|
|
@@ -16,6 +17,7 @@ declare module '@deepseek-ai/dsh-typert-protocol' {
|
|
|
16
17
|
}
|
|
17
18
|
interface TypertRemoteMap {
|
|
18
19
|
'billing/getBalance': (force?: boolean) => Promise<RemoteResult<DeepSeekBalance>>
|
|
20
|
+
'billing/getDelegatedSpend': (sessionId: SessionId, force?: boolean) => Promise<RemoteResult<DeepSeekDelegatedSpend>>
|
|
19
21
|
'billing/getSessionSpend': (sessionId: SessionId) => Promise<RemoteResult<DeepSeekSessionSpend>>
|
|
20
22
|
'billing/getSessionTurnSpends': (sessionId: SessionId) => Promise<RemoteResult<DeepSeekSessionTurnSpends>>
|
|
21
23
|
'billing/getTodaySessionsSpend': (force?: boolean) => Promise<RemoteResult<DeepSeekTodaySessionsSpend>>
|
|
@@ -11,6 +11,26 @@ const _rayadesu_dsh_llm_billing_billing_getBalance_result$schema = z.object({
|
|
|
11
11
|
'toppedUp': z.string(),
|
|
12
12
|
})),
|
|
13
13
|
})
|
|
14
|
+
const _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_parameter_0$schema = z.intersection(z.string(), z.unknown())
|
|
15
|
+
const _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_parameter_1$schema = z.union([z.undefined(), z.literal(false), z.literal(true)])
|
|
16
|
+
const _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_result$schema = z.object({
|
|
17
|
+
'total': z.number(),
|
|
18
|
+
'models': z.array(z.object({
|
|
19
|
+
'model': z.string(),
|
|
20
|
+
'displayName': z.string(),
|
|
21
|
+
'cost': z.number(),
|
|
22
|
+
'peakCost': z.number(),
|
|
23
|
+
'offPeakCost': z.number(),
|
|
24
|
+
'cacheHitInputTokens': z.number(),
|
|
25
|
+
'cacheMissInputTokens': z.number(),
|
|
26
|
+
'outputTokens': z.number(),
|
|
27
|
+
'cacheHitInputCost': z.number(),
|
|
28
|
+
'cacheMissInputCost': z.number(),
|
|
29
|
+
'outputCost': z.number(),
|
|
30
|
+
})),
|
|
31
|
+
'isSubagent': z.boolean(),
|
|
32
|
+
'crossedDay': z.boolean(),
|
|
33
|
+
})
|
|
14
34
|
const _rayadesu_dsh_llm_billing_billing_getSessionSpend_parameter_0$schema = z.intersection(z.string(), z.unknown())
|
|
15
35
|
const _rayadesu_dsh_llm_billing_billing_getSessionSpend_result$schema = z.object({
|
|
16
36
|
'total': z.number(),
|
|
@@ -41,6 +61,7 @@ const _rayadesu_dsh_llm_billing_billing_getTodaySessionsSpend_result$schema = z.
|
|
|
41
61
|
'sessionId': z.intersection(z.string(), z.unknown()),
|
|
42
62
|
'title': z.union([z.literal(null), z.string()]),
|
|
43
63
|
'total': z.number(),
|
|
64
|
+
'ownTotal': z.number(),
|
|
44
65
|
})),
|
|
45
66
|
})
|
|
46
67
|
const _rayadesu_dsh_llm_billing_billing_getTodaySpend_parameter_0$schema = z.union([z.undefined(), z.literal(false), z.literal(true)])
|
|
@@ -85,6 +106,7 @@ export const TYPERT_REMOTE = {
|
|
|
85
106
|
mode: 'strict',
|
|
86
107
|
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getBalance:force',
|
|
87
108
|
schema: _rayadesu_dsh_llm_billing_billing_getBalance_parameter_0$schema,
|
|
109
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getBalance_parameter_0$schema,
|
|
88
110
|
},
|
|
89
111
|
},
|
|
90
112
|
],
|
|
@@ -92,8 +114,48 @@ export const TYPERT_REMOTE = {
|
|
|
92
114
|
mode: 'strict',
|
|
93
115
|
typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekBalance',
|
|
94
116
|
schema: _rayadesu_dsh_llm_billing_billing_getBalance_result$schema,
|
|
117
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getBalance_result$schema,
|
|
118
|
+
},
|
|
119
|
+
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":172,"column":3},
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: '@rayadesu/dsh-llm-billing#billing/getDelegatedSpend',
|
|
123
|
+
service: 'billing',
|
|
124
|
+
namespace: 'billing',
|
|
125
|
+
method: 'getDelegatedSpend',
|
|
126
|
+
invocation: { kind: 'direct' },
|
|
127
|
+
parameters: [
|
|
128
|
+
{
|
|
129
|
+
name: 'sessionId',
|
|
130
|
+
wire: 'sessionId',
|
|
131
|
+
source: 'json',
|
|
132
|
+
codec: {
|
|
133
|
+
mode: 'strict',
|
|
134
|
+
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getDelegatedSpend:sessionId',
|
|
135
|
+
schema: _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_parameter_0$schema,
|
|
136
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_parameter_0$schema,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: 'force',
|
|
141
|
+
wire: 'force',
|
|
142
|
+
source: 'json',
|
|
143
|
+
acceptsUndefined: true,
|
|
144
|
+
codec: {
|
|
145
|
+
mode: 'strict',
|
|
146
|
+
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getDelegatedSpend:force',
|
|
147
|
+
schema: _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_parameter_1$schema,
|
|
148
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_parameter_1$schema,
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
result: {
|
|
153
|
+
mode: 'strict',
|
|
154
|
+
typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekDelegatedSpend',
|
|
155
|
+
schema: _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_result$schema,
|
|
156
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getDelegatedSpend_result$schema,
|
|
95
157
|
},
|
|
96
|
-
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":
|
|
158
|
+
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":226,"column":3},
|
|
97
159
|
},
|
|
98
160
|
{
|
|
99
161
|
id: '@rayadesu/dsh-llm-billing#billing/getSessionSpend',
|
|
@@ -110,6 +172,7 @@ export const TYPERT_REMOTE = {
|
|
|
110
172
|
mode: 'strict',
|
|
111
173
|
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getSessionSpend:sessionId',
|
|
112
174
|
schema: _rayadesu_dsh_llm_billing_billing_getSessionSpend_parameter_0$schema,
|
|
175
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getSessionSpend_parameter_0$schema,
|
|
113
176
|
},
|
|
114
177
|
},
|
|
115
178
|
],
|
|
@@ -117,8 +180,9 @@ export const TYPERT_REMOTE = {
|
|
|
117
180
|
mode: 'strict',
|
|
118
181
|
typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekSessionSpend',
|
|
119
182
|
schema: _rayadesu_dsh_llm_billing_billing_getSessionSpend_result$schema,
|
|
183
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getSessionSpend_result$schema,
|
|
120
184
|
},
|
|
121
|
-
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":
|
|
185
|
+
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":183,"column":3},
|
|
122
186
|
},
|
|
123
187
|
{
|
|
124
188
|
id: '@rayadesu/dsh-llm-billing#billing/getSessionTurnSpends',
|
|
@@ -135,6 +199,7 @@ export const TYPERT_REMOTE = {
|
|
|
135
199
|
mode: 'strict',
|
|
136
200
|
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getSessionTurnSpends:sessionId',
|
|
137
201
|
schema: _rayadesu_dsh_llm_billing_billing_getSessionTurnSpends_parameter_0$schema,
|
|
202
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getSessionTurnSpends_parameter_0$schema,
|
|
138
203
|
},
|
|
139
204
|
},
|
|
140
205
|
],
|
|
@@ -142,8 +207,9 @@ export const TYPERT_REMOTE = {
|
|
|
142
207
|
mode: 'strict',
|
|
143
208
|
typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekSessionTurnSpends',
|
|
144
209
|
schema: _rayadesu_dsh_llm_billing_billing_getSessionTurnSpends_result$schema,
|
|
210
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getSessionTurnSpends_result$schema,
|
|
145
211
|
},
|
|
146
|
-
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":
|
|
212
|
+
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":251,"column":3},
|
|
147
213
|
},
|
|
148
214
|
{
|
|
149
215
|
id: '@rayadesu/dsh-llm-billing#billing/getTodaySessionsSpend',
|
|
@@ -161,6 +227,7 @@ export const TYPERT_REMOTE = {
|
|
|
161
227
|
mode: 'strict',
|
|
162
228
|
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getTodaySessionsSpend:force',
|
|
163
229
|
schema: _rayadesu_dsh_llm_billing_billing_getTodaySessionsSpend_parameter_0$schema,
|
|
230
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getTodaySessionsSpend_parameter_0$schema,
|
|
164
231
|
},
|
|
165
232
|
},
|
|
166
233
|
],
|
|
@@ -168,8 +235,9 @@ export const TYPERT_REMOTE = {
|
|
|
168
235
|
mode: 'strict',
|
|
169
236
|
typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekTodaySessionsSpend',
|
|
170
237
|
schema: _rayadesu_dsh_llm_billing_billing_getTodaySessionsSpend_result$schema,
|
|
238
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getTodaySessionsSpend_result$schema,
|
|
171
239
|
},
|
|
172
|
-
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":
|
|
240
|
+
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":211,"column":3},
|
|
173
241
|
},
|
|
174
242
|
{
|
|
175
243
|
id: '@rayadesu/dsh-llm-billing#billing/getTodaySpend',
|
|
@@ -187,6 +255,7 @@ export const TYPERT_REMOTE = {
|
|
|
187
255
|
mode: 'strict',
|
|
188
256
|
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getTodaySpend:force',
|
|
189
257
|
schema: _rayadesu_dsh_llm_billing_billing_getTodaySpend_parameter_0$schema,
|
|
258
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getTodaySpend_parameter_0$schema,
|
|
190
259
|
},
|
|
191
260
|
},
|
|
192
261
|
],
|
|
@@ -194,8 +263,9 @@ export const TYPERT_REMOTE = {
|
|
|
194
263
|
mode: 'strict',
|
|
195
264
|
typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekTodaySpend',
|
|
196
265
|
schema: _rayadesu_dsh_llm_billing_billing_getTodaySpend_result$schema,
|
|
266
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getTodaySpend_result$schema,
|
|
197
267
|
},
|
|
198
|
-
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":
|
|
268
|
+
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":196,"column":3},
|
|
199
269
|
},
|
|
200
270
|
{
|
|
201
271
|
id: '@rayadesu/dsh-llm-billing#billing/getTurnSpend',
|
|
@@ -212,6 +282,7 @@ export const TYPERT_REMOTE = {
|
|
|
212
282
|
mode: 'strict',
|
|
213
283
|
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getTurnSpend:sessionId',
|
|
214
284
|
schema: _rayadesu_dsh_llm_billing_billing_getTurnSpend_parameter_0$schema,
|
|
285
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getTurnSpend_parameter_0$schema,
|
|
215
286
|
},
|
|
216
287
|
},
|
|
217
288
|
{
|
|
@@ -222,6 +293,7 @@ export const TYPERT_REMOTE = {
|
|
|
222
293
|
mode: 'strict',
|
|
223
294
|
typeSymbol: '@rayadesu/dsh-llm-billing#billing/getTurnSpend:messageId',
|
|
224
295
|
schema: _rayadesu_dsh_llm_billing_billing_getTurnSpend_parameter_1$schema,
|
|
296
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getTurnSpend_parameter_1$schema,
|
|
225
297
|
},
|
|
226
298
|
},
|
|
227
299
|
],
|
|
@@ -229,8 +301,9 @@ export const TYPERT_REMOTE = {
|
|
|
229
301
|
mode: 'strict',
|
|
230
302
|
typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekTurnSpend',
|
|
231
303
|
schema: _rayadesu_dsh_llm_billing_billing_getTurnSpend_result$schema,
|
|
304
|
+
create: () => _rayadesu_dsh_llm_billing_billing_getTurnSpend_result$schema,
|
|
232
305
|
},
|
|
233
|
-
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":
|
|
306
|
+
sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":239,"column":3},
|
|
234
307
|
},
|
|
235
308
|
],
|
|
236
309
|
}
|
package/lib/types/balance.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import type { Context } from '@deepseek-ai/cordis';
|
|
10
10
|
import type { SessionId } from '@deepseek-ai/dsh-session';
|
|
11
11
|
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
12
|
-
import type { DeepSeekBalance, DeepSeekSessionSpend, DeepSeekSessionTurnSpends, DeepSeekTodaySessionsSpend, DeepSeekTodaySpend, DeepSeekTurnSpend } from './types.ts';
|
|
12
|
+
import type { DeepSeekBalance, DeepSeekDelegatedSpend, DeepSeekSessionSpend, DeepSeekSessionTurnSpends, DeepSeekTodaySessionsSpend, DeepSeekTodaySpend, DeepSeekTurnSpend } from './types.ts';
|
|
13
13
|
/**
|
|
14
14
|
* Parse and validate the DeepSeek balance response at the wire boundary.
|
|
15
15
|
* @param body - decoded JSON response body.
|
|
@@ -47,6 +47,13 @@ export interface DeepSeekBalanceGatewayOptions {
|
|
|
47
47
|
* window like {@link fetchTodaySpend}.
|
|
48
48
|
*/
|
|
49
49
|
fetchTodaySessionsSpend: (force?: boolean) => Promise<DeepSeekTodaySessionsSpend>;
|
|
50
|
+
/**
|
|
51
|
+
* Compute the subagent part of one conversation's billed spend through the
|
|
52
|
+
* plugin's resolved facts: every subagent session that session delegated,
|
|
53
|
+
* transitively, across every day. Served from the same cached pass as
|
|
54
|
+
* {@link fetchTodaySpend}; `force` bypasses the time window like it does.
|
|
55
|
+
*/
|
|
56
|
+
fetchDelegatedSpend: (sessionId: SessionId, force?: boolean) => Promise<DeepSeekDelegatedSpend>;
|
|
50
57
|
/**
|
|
51
58
|
* Compute one completed Turn's billed spend through the plugin's resolved
|
|
52
59
|
* facts, identified by its closing assistant message id.
|
|
@@ -99,12 +106,25 @@ export declare class DeepSeekBalanceGateway extends TypertRemoteService {
|
|
|
99
106
|
/**
|
|
100
107
|
* Read today's billed spend per session, restricted to the queried Beijing
|
|
101
108
|
* day. Rows carry the session's durable title and sort by cost descending;
|
|
102
|
-
* sessions with no priced usage on the day are omitted
|
|
109
|
+
* sessions with no priced usage on the day are omitted, and every subagent
|
|
110
|
+
* session is merged into the row of the top-level session that delegated it,
|
|
111
|
+
* so the ranking lists conversations rather than delegations.
|
|
103
112
|
* @param force - bypass the host-side 60s cache (manual refresh); omitted
|
|
104
113
|
* means a cached read.
|
|
105
114
|
* @returns today's per-session rows, highest first.
|
|
106
115
|
*/
|
|
107
116
|
getTodaySessionsSpend(force?: boolean): Promise<DeepSeekTodaySessionsSpend>;
|
|
117
|
+
/**
|
|
118
|
+
* Read the subagent part of one conversation's billed spend: every subagent
|
|
119
|
+
* session the given session delegated, transitively, across every day (a
|
|
120
|
+
* session's own log cannot price its delegation children). `isSubagent`
|
|
121
|
+
* reports whether the queried session is itself a delegated child.
|
|
122
|
+
* @param sessionId - the session whose delegated subtree to sum.
|
|
123
|
+
* @param force - bypass the host-side 60s cache (manual refresh); omitted
|
|
124
|
+
* means a cached read.
|
|
125
|
+
* @returns the delegated subtotal plus its per-model rows.
|
|
126
|
+
*/
|
|
127
|
+
getDelegatedSpend(sessionId: SessionId, force?: boolean): Promise<DeepSeekDelegatedSpend>;
|
|
108
128
|
/**
|
|
109
129
|
* Read one completed Turn's billed spend (same per-event pricing as
|
|
110
130
|
* {@link priceEvent}).
|
package/lib/types/balance.js
CHANGED
|
@@ -137,6 +137,7 @@ let DeepSeekBalanceGateway = (() => {
|
|
|
137
137
|
let _getSessionSpend_decorators;
|
|
138
138
|
let _getTodaySpend_decorators;
|
|
139
139
|
let _getTodaySessionsSpend_decorators;
|
|
140
|
+
let _getDelegatedSpend_decorators;
|
|
140
141
|
let _getTurnSpend_decorators;
|
|
141
142
|
let _getSessionTurnSpends_decorators;
|
|
142
143
|
return class DeepSeekBalanceGateway extends _classSuper {
|
|
@@ -146,12 +147,14 @@ let DeepSeekBalanceGateway = (() => {
|
|
|
146
147
|
_getSessionSpend_decorators = [Remote('getSessionSpend')];
|
|
147
148
|
_getTodaySpend_decorators = [Remote('getTodaySpend')];
|
|
148
149
|
_getTodaySessionsSpend_decorators = [Remote('getTodaySessionsSpend')];
|
|
150
|
+
_getDelegatedSpend_decorators = [Remote('getDelegatedSpend')];
|
|
149
151
|
_getTurnSpend_decorators = [Remote('getTurnSpend')];
|
|
150
152
|
_getSessionTurnSpends_decorators = [Remote('getSessionTurnSpends')];
|
|
151
153
|
__esDecorate(this, null, _getBalance_decorators, { kind: "method", name: "getBalance", static: false, private: false, access: { has: obj => "getBalance" in obj, get: obj => obj.getBalance }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
152
154
|
__esDecorate(this, null, _getSessionSpend_decorators, { kind: "method", name: "getSessionSpend", static: false, private: false, access: { has: obj => "getSessionSpend" in obj, get: obj => obj.getSessionSpend }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
153
155
|
__esDecorate(this, null, _getTodaySpend_decorators, { kind: "method", name: "getTodaySpend", static: false, private: false, access: { has: obj => "getTodaySpend" in obj, get: obj => obj.getTodaySpend }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
154
156
|
__esDecorate(this, null, _getTodaySessionsSpend_decorators, { kind: "method", name: "getTodaySessionsSpend", static: false, private: false, access: { has: obj => "getTodaySessionsSpend" in obj, get: obj => obj.getTodaySessionsSpend }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
157
|
+
__esDecorate(this, null, _getDelegatedSpend_decorators, { kind: "method", name: "getDelegatedSpend", static: false, private: false, access: { has: obj => "getDelegatedSpend" in obj, get: obj => obj.getDelegatedSpend }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
155
158
|
__esDecorate(this, null, _getTurnSpend_decorators, { kind: "method", name: "getTurnSpend", static: false, private: false, access: { has: obj => "getTurnSpend" in obj, get: obj => obj.getTurnSpend }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
156
159
|
__esDecorate(this, null, _getSessionTurnSpends_decorators, { kind: "method", name: "getSessionTurnSpends", static: false, private: false, access: { has: obj => "getSessionTurnSpends" in obj, get: obj => obj.getSessionTurnSpends }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
157
160
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
@@ -199,7 +202,9 @@ let DeepSeekBalanceGateway = (() => {
|
|
|
199
202
|
/**
|
|
200
203
|
* Read today's billed spend per session, restricted to the queried Beijing
|
|
201
204
|
* day. Rows carry the session's durable title and sort by cost descending;
|
|
202
|
-
* sessions with no priced usage on the day are omitted
|
|
205
|
+
* sessions with no priced usage on the day are omitted, and every subagent
|
|
206
|
+
* session is merged into the row of the top-level session that delegated it,
|
|
207
|
+
* so the ranking lists conversations rather than delegations.
|
|
203
208
|
* @param force - bypass the host-side 60s cache (manual refresh); omitted
|
|
204
209
|
* means a cached read.
|
|
205
210
|
* @returns today's per-session rows, highest first.
|
|
@@ -207,6 +212,19 @@ let DeepSeekBalanceGateway = (() => {
|
|
|
207
212
|
getTodaySessionsSpend(force) {
|
|
208
213
|
return this.options.fetchTodaySessionsSpend(force ?? false);
|
|
209
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Read the subagent part of one conversation's billed spend: every subagent
|
|
217
|
+
* session the given session delegated, transitively, across every day (a
|
|
218
|
+
* session's own log cannot price its delegation children). `isSubagent`
|
|
219
|
+
* reports whether the queried session is itself a delegated child.
|
|
220
|
+
* @param sessionId - the session whose delegated subtree to sum.
|
|
221
|
+
* @param force - bypass the host-side 60s cache (manual refresh); omitted
|
|
222
|
+
* means a cached read.
|
|
223
|
+
* @returns the delegated subtotal plus its per-model rows.
|
|
224
|
+
*/
|
|
225
|
+
getDelegatedSpend(sessionId, force) {
|
|
226
|
+
return this.options.fetchDelegatedSpend(sessionId, force ?? false);
|
|
227
|
+
}
|
|
210
228
|
/**
|
|
211
229
|
* Read one completed Turn's billed spend (same per-event pricing as
|
|
212
230
|
* {@link priceEvent}).
|
package/lib/types/index.d.ts
CHANGED
|
@@ -29,8 +29,8 @@ export type { BillingConfig, BillingConfigModel, BillingEventContribution, Billi
|
|
|
29
29
|
export type * from './types.ts';
|
|
30
30
|
export { BILLING_UNIT_KEY, billingTodaySpendDefinition, foldBillingUnit, foldOwnBilling } from './projection.ts';
|
|
31
31
|
export type { BillingUnitFold, BillingUnitState } from './projection.ts';
|
|
32
|
-
export { foldSessionTitle, liveSessionEvents, persistenceInspect, persistenceListSnapshots, TodaySpendCache, TodaySpendScanner } from './today-spend.ts';
|
|
33
|
-
export type { ScannerPersistedHeader, ScannerPersistence, ScannerPersistenceHandle, ScannerPersistenceLegacy, ScannerPersistedRead, ScannerSession, TodaySpendScannerDeps } from './today-spend.ts';
|
|
32
|
+
export { delegatedSpendOf, foldSessionTitle, isSubagentSession, liveSessionEvents, persistenceInspect, persistenceListSnapshots, rollUpSubagentSpend, TodaySpendCache, TodaySpendScanner, topLevelSessionOf, } from './today-spend.ts';
|
|
33
|
+
export type { ColdResolution, ScannerPersistedHeader, ScannerPersistence, ScannerPersistenceHandle, ScannerPersistenceLegacy, ScannerPersistedRead, ScannerSession, SessionHeaderSlice, SessionLineage, TodaySpendScannerDeps, } from './today-spend.ts';
|
|
34
34
|
export declare const name = "llm-billing";
|
|
35
35
|
/** Public API default; deployments may point elsewhere via $DEEPSEEK_BASE_URL. */
|
|
36
36
|
export declare const PUBLIC_BASE_URL = "https://api.deepseek.com";
|
package/lib/types/index.js
CHANGED
|
@@ -25,13 +25,13 @@ import { assertUsableApiKey, LlmError } from '@deepseek-ai/dsh-llm';
|
|
|
25
25
|
import { credentialRef } from '@deepseek-ai/dsh-credentials';
|
|
26
26
|
import { launchEnvironmentOf } from '@deepseek-ai/dsh-launch-environment';
|
|
27
27
|
import { DeepSeekBalanceGateway, fetchDeepSeekBalance } from "./balance.js";
|
|
28
|
-
import { computeSessionSpend, computeTurnSpend, DEFAULT_MODEL_PRICING, DEFAULT_PEAK_HOURS, forkBoundaryOf, mergeTodaySpend, resolveBilling, SessionTurnSpendFolder, } from "./billing.js";
|
|
28
|
+
import { beijingDayKey, computeSessionSpend, computeTurnSpend, DEFAULT_MODEL_PRICING, DEFAULT_PEAK_HOURS, forkBoundaryOf, mergeTodaySpend, resolveBilling, SessionTurnSpendFolder, } from "./billing.js";
|
|
29
29
|
import { billingTodaySpendDefinition } from "./projection.js";
|
|
30
|
-
import { liveSessionEvents, persistenceInspect, TodaySpendCache, TodaySpendScanner } from "./today-spend.js";
|
|
30
|
+
import { delegatedSpendOf, isSubagentSession, liveSessionEvents, persistenceInspect, TodaySpendCache, TodaySpendScanner } from "./today-spend.js";
|
|
31
31
|
export { DeepSeekBalanceGateway, fetchDeepSeekBalance, parseDeepSeekBalance } from "./balance.js";
|
|
32
32
|
export { addEventContribution, applyBillingEvent, beijingDayKey, BillingFolder, computeSessionSpend, computeSessionTurnSpends, computeTodaySpend, computeTurnSpend, DEFAULT_MODEL_PRICING, DEFAULT_PEAK_HOURS, emptyBillingFoldState, emptyTodaySpend, FLASH_SERIES_RATE_CHANGE_AT, forkBoundaryOf, isPeak, isSeededSession, mergeTodaySpend, negateSpend, priceEvent, priceUsage, resolveBilling, SessionTurnSpendFolder, SpendAccumulator, subtractSpend, V4_PRO_ROUTE_SWITCH_AT, } from "./billing.js";
|
|
33
33
|
export { BILLING_UNIT_KEY, billingTodaySpendDefinition, foldBillingUnit, foldOwnBilling } from "./projection.js";
|
|
34
|
-
export { foldSessionTitle, liveSessionEvents, persistenceInspect, persistenceListSnapshots, TodaySpendCache, TodaySpendScanner } from "./today-spend.js";
|
|
34
|
+
export { delegatedSpendOf, foldSessionTitle, isSubagentSession, liveSessionEvents, persistenceInspect, persistenceListSnapshots, rollUpSubagentSpend, TodaySpendCache, TodaySpendScanner, topLevelSessionOf, } from "./today-spend.js";
|
|
35
35
|
export const name = 'llm-billing';
|
|
36
36
|
const DEFAULT_API_KEY_ENV = 'DEEPSEEK_API_KEY';
|
|
37
37
|
const BASE_URL_ENV = 'DEEPSEEK_BASE_URL';
|
|
@@ -237,11 +237,15 @@ function createUnitRegistrar(ctx, unit) {
|
|
|
237
237
|
* events path serves today's spend.
|
|
238
238
|
* - plans A1–A3: the scanner chooses the projection path when the registry
|
|
239
239
|
* is composed, the events path otherwise.
|
|
240
|
+
* All three reads come from ONE cached pass: the day's aggregate, its
|
|
241
|
+
* per-session ranking, and the delegated-subagent subtree of a conversation
|
|
242
|
+
* (the same pass folds each session's whole-session total, so the subtree read
|
|
243
|
+
* costs no second scan).
|
|
240
244
|
* @param ctx - plugin context.
|
|
241
245
|
* @param facts - resolved endpoint, credential, pricing, and catalog facts.
|
|
242
246
|
* @param unit - the shared projection unit definition.
|
|
243
247
|
* @param ensureUnit - idempotent unit registrar (last-resort registration).
|
|
244
|
-
* @returns the
|
|
248
|
+
* @returns the three today-spend loaders.
|
|
245
249
|
*/
|
|
246
250
|
function createTodaySpendLoaders(ctx, facts, unit, ensureUnit) {
|
|
247
251
|
const scanner = new TodaySpendScanner({
|
|
@@ -260,6 +264,20 @@ function createTodaySpendLoaders(ctx, facts, unit, ensureUnit) {
|
|
|
260
264
|
return {
|
|
261
265
|
fetchTodaySpend: async (force = false) => (await todayCache.get(force)).aggregate,
|
|
262
266
|
fetchTodaySessionsSpend: async (force = false) => ({ sessions: (await todayCache.get(force)).sessions }),
|
|
267
|
+
fetchDelegatedSpend: async (sessionId, force = false) => {
|
|
268
|
+
const detail = await todayCache.get(force);
|
|
269
|
+
const spend = delegatedSpendOf(sessionId, detail.ownSpend, detail.lineage);
|
|
270
|
+
const createdAt = detail.createdAt.get(sessionId);
|
|
271
|
+
return {
|
|
272
|
+
total: spend.total,
|
|
273
|
+
models: spend.models,
|
|
274
|
+
isSubagent: isSubagentSession(detail.lineage.get(sessionId)),
|
|
275
|
+
// Only a session born on an EARLIER Beijing day can have a today share
|
|
276
|
+
// worth showing. An unresolved creation instant reads as "no crossing":
|
|
277
|
+
// a share the panel cannot prove must stay hidden.
|
|
278
|
+
crossedDay: createdAt !== undefined && beijingDayKey(new Date(createdAt)) !== detail.dayKey,
|
|
279
|
+
};
|
|
280
|
+
},
|
|
263
281
|
};
|
|
264
282
|
}
|
|
265
283
|
/** One completed Turn's spend loader, located by its closing message id. */
|
|
@@ -345,7 +363,7 @@ export function apply(ctx, config) {
|
|
|
345
363
|
ctx.on('session/created', ensureUnit);
|
|
346
364
|
const fetchBalance = createBalanceFetcher(ctx, facts);
|
|
347
365
|
const fetchSessionSpend = createSessionSpendFetcher(ctx, facts);
|
|
348
|
-
const { fetchTodaySpend, fetchTodaySessionsSpend } = createTodaySpendLoaders(ctx, facts, unit, ensureUnit);
|
|
366
|
+
const { fetchTodaySpend, fetchTodaySessionsSpend, fetchDelegatedSpend } = createTodaySpendLoaders(ctx, facts, unit, ensureUnit);
|
|
349
367
|
const fetchTurnSpend = createTurnSpendFetcher(ctx, facts);
|
|
350
368
|
const fetchTurnSpends = createTurnSpendsFetcher(ctx, facts);
|
|
351
369
|
new DeepSeekBalanceGateway(ctx, {
|
|
@@ -353,6 +371,7 @@ export function apply(ctx, config) {
|
|
|
353
371
|
fetchSessionSpend,
|
|
354
372
|
fetchTodaySpend,
|
|
355
373
|
fetchTodaySessionsSpend,
|
|
374
|
+
fetchDelegatedSpend,
|
|
356
375
|
fetchTurnSpend,
|
|
357
376
|
fetchTurnSpends,
|
|
358
377
|
});
|