@rayadesu/dsh-llm-billing 0.2.1 → 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/lib/invariant.js CHANGED
@@ -1,9 +1,9 @@
1
1
  //#region lib/types/invariant.js
2
2
  /**
3
- * Package-owned invariant companion for `@deepseek-ai/dsh-llm-billing`.
4
- * @module @deepseek-ai/dsh-llm-billing/invariant
3
+ * Package-owned invariant companion for `@rayadesu/dsh-llm-billing`.
4
+ * @module @rayadesu/dsh-llm-billing/invariant
5
5
  */
6
- const PACKAGE_NAME = "@deepseek-ai/dsh-llm-billing";
6
+ const PACKAGE_NAME = "@rayadesu/dsh-llm-billing";
7
7
  /** Cordis companion plugin name. */
8
8
  const name = "llm-billing-invariant";
9
9
  /** Service required before the companion can reserve package ownership. */
@@ -1,7 +1,7 @@
1
1
  /* Generated by @deepseek-ai/dsh-typert-generator from FaceModel — do not edit. */
2
2
  import { z } from 'zod'
3
3
 
4
- const _deepseek_ai_dsh_llm_billing_billing_getBalance_result$schema = z.object({
4
+ const _rayadesu_dsh_llm_billing_billing_getBalance_result$schema = z.object({
5
5
  'isAvailable': z.boolean(),
6
6
  'lines': z.array(z.object({
7
7
  'currency': z.string(),
@@ -10,8 +10,8 @@ const _deepseek_ai_dsh_llm_billing_billing_getBalance_result$schema = z.object({
10
10
  'toppedUp': z.string(),
11
11
  })),
12
12
  })
13
- const _deepseek_ai_dsh_llm_billing_billing_getSessionSpend_parameter_0$schema = z.intersection(z.string(), z.unknown())
14
- const _deepseek_ai_dsh_llm_billing_billing_getSessionSpend_result$schema = z.object({
13
+ const _rayadesu_dsh_llm_billing_billing_getSessionSpend_parameter_0$schema = z.intersection(z.string(), z.unknown())
14
+ const _rayadesu_dsh_llm_billing_billing_getSessionSpend_result$schema = z.object({
15
15
  'total': z.number(),
16
16
  'models': z.array(z.object({
17
17
  'model': z.string(),
@@ -27,7 +27,8 @@ const _deepseek_ai_dsh_llm_billing_billing_getSessionSpend_result$schema = z.obj
27
27
  'outputCost': z.number(),
28
28
  })),
29
29
  })
30
- const _deepseek_ai_dsh_llm_billing_billing_getTodaySpend_result$schema = z.object({
30
+ const _rayadesu_dsh_llm_billing_billing_getTodaySpend_parameter_0$schema = z.union([z.undefined(), z.literal(false), z.literal(true)])
31
+ const _rayadesu_dsh_llm_billing_billing_getTodaySpend_result$schema = z.object({
31
32
  'total': z.number(),
32
33
  'models': z.array(z.object({
33
34
  'model': z.string(),
@@ -45,13 +46,13 @@ const _deepseek_ai_dsh_llm_billing_billing_getTodaySpend_result$schema = z.objec
45
46
  })
46
47
 
47
48
  export const TYPERT = {
48
- package: '@deepseek-ai/dsh-llm-billing',
49
+ package: '@rayadesu/dsh-llm-billing',
49
50
  face: 'host',
50
51
  schemas: [
51
52
  ],
52
53
  invocations: [
53
54
  {
54
- id: '@deepseek-ai/dsh-llm-billing#billing/getBalance',
55
+ id: '@rayadesu/dsh-llm-billing#billing/getBalance',
55
56
  service: 'billing',
56
57
  namespace: 'billing',
57
58
  method: 'getBalance',
@@ -60,13 +61,13 @@ export const TYPERT = {
60
61
  ],
61
62
  result: {
62
63
  mode: 'strict',
63
- typeSymbol: '@deepseek-ai/dsh-llm-billing/types#DeepSeekBalance',
64
- schema: _deepseek_ai_dsh_llm_billing_billing_getBalance_result$schema,
64
+ typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekBalance',
65
+ schema: _rayadesu_dsh_llm_billing_billing_getBalance_result$schema,
65
66
  },
66
- sourceLocation: {"file":"packages/llm/llm-billing/src/balance.ts","line":139,"column":3},
67
+ sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":143,"column":3},
67
68
  },
68
69
  {
69
- id: '@deepseek-ai/dsh-llm-billing#billing/getSessionSpend',
70
+ id: '@rayadesu/dsh-llm-billing#billing/getSessionSpend',
70
71
  service: 'billing',
71
72
  namespace: 'billing',
72
73
  method: 'getSessionSpend',
@@ -78,32 +79,43 @@ export const TYPERT = {
78
79
  source: 'json',
79
80
  codec: {
80
81
  mode: 'strict',
81
- typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
82
- schema: _deepseek_ai_dsh_llm_billing_billing_getSessionSpend_parameter_0$schema,
82
+ typeSymbol: '@rayadesu/dsh-llm-billing#billing/getSessionSpend:sessionId',
83
+ schema: _rayadesu_dsh_llm_billing_billing_getSessionSpend_parameter_0$schema,
83
84
  },
84
85
  },
85
86
  ],
86
87
  result: {
87
88
  mode: 'strict',
88
- typeSymbol: '@deepseek-ai/dsh-llm-billing/types#DeepSeekSessionSpend',
89
- schema: _deepseek_ai_dsh_llm_billing_billing_getSessionSpend_result$schema,
89
+ typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekSessionSpend',
90
+ schema: _rayadesu_dsh_llm_billing_billing_getSessionSpend_result$schema,
90
91
  },
91
- sourceLocation: {"file":"packages/llm/llm-billing/src/balance.ts","line":149,"column":3},
92
+ sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":154,"column":3},
92
93
  },
93
94
  {
94
- id: '@deepseek-ai/dsh-llm-billing#billing/getTodaySpend',
95
+ id: '@rayadesu/dsh-llm-billing#billing/getTodaySpend',
95
96
  service: 'billing',
96
97
  namespace: 'billing',
97
98
  method: 'getTodaySpend',
98
99
  invocation: { kind: 'direct' },
99
100
  parameters: [
101
+ {
102
+ name: 'force',
103
+ wire: 'force',
104
+ source: 'json',
105
+ acceptsUndefined: true,
106
+ codec: {
107
+ mode: 'strict',
108
+ typeSymbol: '@rayadesu/dsh-llm-billing#billing/getTodaySpend:force',
109
+ schema: _rayadesu_dsh_llm_billing_billing_getTodaySpend_parameter_0$schema,
110
+ },
111
+ },
100
112
  ],
101
113
  result: {
102
114
  mode: 'strict',
103
- typeSymbol: '@deepseek-ai/dsh-llm-billing/types#DeepSeekTodaySpend',
104
- schema: _deepseek_ai_dsh_llm_billing_billing_getTodaySpend_result$schema,
115
+ typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekTodaySpend',
116
+ schema: _rayadesu_dsh_llm_billing_billing_getTodaySpend_result$schema,
105
117
  },
106
- sourceLocation: {"file":"packages/llm/llm-billing/src/balance.ts","line":159,"column":3},
118
+ sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":167,"column":3},
107
119
  },
108
120
  ],
109
121
  model: {
@@ -3,19 +3,18 @@ import type {
3
3
  RemoteResult,
4
4
  TypertRemoteContribution,
5
5
  } from '@deepseek-ai/dsh-typert-protocol'
6
- import type { DeepSeekBalance, DeepSeekSessionSpend, DeepSeekTodaySpend } from '@deepseek-ai/dsh-llm-billing/types'
7
- import type { SessionId } from '@deepseek-ai/dsh-session/types'
6
+ import type { DeepSeekBalance, DeepSeekSessionSpend, DeepSeekTodaySpend } from '@rayadesu/dsh-llm-billing/types'
8
7
 
9
8
  declare module '@deepseek-ai/dsh-typert-protocol' {
10
9
  interface TypertRemoteNamespace$62696c6c696e67 {
11
10
  getBalance: () => Promise<RemoteResult<DeepSeekBalance>>
12
11
  getSessionSpend: (sessionId: SessionId) => Promise<RemoteResult<DeepSeekSessionSpend>>
13
- getTodaySpend: () => Promise<RemoteResult<DeepSeekTodaySpend>>
12
+ getTodaySpend: (force?: boolean) => Promise<RemoteResult<DeepSeekTodaySpend>>
14
13
  }
15
14
  interface TypertRemoteMap {
16
15
  'billing/getBalance': () => Promise<RemoteResult<DeepSeekBalance>>
17
16
  'billing/getSessionSpend': (sessionId: SessionId) => Promise<RemoteResult<DeepSeekSessionSpend>>
18
- 'billing/getTodaySpend': () => Promise<RemoteResult<DeepSeekTodaySpend>>
17
+ 'billing/getTodaySpend': (force?: boolean) => Promise<RemoteResult<DeepSeekTodaySpend>>
19
18
  }
20
19
  interface TypertRemoteNamespaceMap {
21
20
  'billing': TypertRemoteNamespace$62696c6c696e67
@@ -1,7 +1,7 @@
1
1
  /* Generated by @deepseek-ai/dsh-typert-generator from the Host FaceModel — do not edit. */
2
2
  import { z } from 'zod'
3
3
 
4
- const _deepseek_ai_dsh_llm_billing_billing_getBalance_result$schema = z.object({
4
+ const _rayadesu_dsh_llm_billing_billing_getBalance_result$schema = z.object({
5
5
  'isAvailable': z.boolean(),
6
6
  'lines': z.array(z.object({
7
7
  'currency': z.string(),
@@ -10,8 +10,8 @@ const _deepseek_ai_dsh_llm_billing_billing_getBalance_result$schema = z.object({
10
10
  'toppedUp': z.string(),
11
11
  })),
12
12
  })
13
- const _deepseek_ai_dsh_llm_billing_billing_getSessionSpend_parameter_0$schema = z.intersection(z.string(), z.unknown())
14
- const _deepseek_ai_dsh_llm_billing_billing_getSessionSpend_result$schema = z.object({
13
+ const _rayadesu_dsh_llm_billing_billing_getSessionSpend_parameter_0$schema = z.intersection(z.string(), z.unknown())
14
+ const _rayadesu_dsh_llm_billing_billing_getSessionSpend_result$schema = z.object({
15
15
  'total': z.number(),
16
16
  'models': z.array(z.object({
17
17
  'model': z.string(),
@@ -27,7 +27,8 @@ const _deepseek_ai_dsh_llm_billing_billing_getSessionSpend_result$schema = z.obj
27
27
  'outputCost': z.number(),
28
28
  })),
29
29
  })
30
- const _deepseek_ai_dsh_llm_billing_billing_getTodaySpend_result$schema = z.object({
30
+ const _rayadesu_dsh_llm_billing_billing_getTodaySpend_parameter_0$schema = z.union([z.undefined(), z.literal(false), z.literal(true)])
31
+ const _rayadesu_dsh_llm_billing_billing_getTodaySpend_result$schema = z.object({
31
32
  'total': z.number(),
32
33
  'models': z.array(z.object({
33
34
  'model': z.string(),
@@ -45,10 +46,10 @@ const _deepseek_ai_dsh_llm_billing_billing_getTodaySpend_result$schema = z.objec
45
46
  })
46
47
 
47
48
  export const TYPERT_REMOTE = {
48
- package: '@deepseek-ai/dsh-llm-billing',
49
+ package: '@rayadesu/dsh-llm-billing',
49
50
  descriptors: [
50
51
  {
51
- id: '@deepseek-ai/dsh-llm-billing#billing/getBalance',
52
+ id: '@rayadesu/dsh-llm-billing#billing/getBalance',
52
53
  service: 'billing',
53
54
  namespace: 'billing',
54
55
  method: 'getBalance',
@@ -57,13 +58,13 @@ export const TYPERT_REMOTE = {
57
58
  ],
58
59
  result: {
59
60
  mode: 'strict',
60
- typeSymbol: '@deepseek-ai/dsh-llm-billing/types#DeepSeekBalance',
61
- schema: _deepseek_ai_dsh_llm_billing_billing_getBalance_result$schema,
61
+ typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekBalance',
62
+ schema: _rayadesu_dsh_llm_billing_billing_getBalance_result$schema,
62
63
  },
63
- sourceLocation: {"file":"packages/llm/llm-billing/src/balance.ts","line":139,"column":3},
64
+ sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":143,"column":3},
64
65
  },
65
66
  {
66
- id: '@deepseek-ai/dsh-llm-billing#billing/getSessionSpend',
67
+ id: '@rayadesu/dsh-llm-billing#billing/getSessionSpend',
67
68
  service: 'billing',
68
69
  namespace: 'billing',
69
70
  method: 'getSessionSpend',
@@ -75,32 +76,43 @@ export const TYPERT_REMOTE = {
75
76
  source: 'json',
76
77
  codec: {
77
78
  mode: 'strict',
78
- typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
79
- schema: _deepseek_ai_dsh_llm_billing_billing_getSessionSpend_parameter_0$schema,
79
+ typeSymbol: '@rayadesu/dsh-llm-billing#billing/getSessionSpend:sessionId',
80
+ schema: _rayadesu_dsh_llm_billing_billing_getSessionSpend_parameter_0$schema,
80
81
  },
81
82
  },
82
83
  ],
83
84
  result: {
84
85
  mode: 'strict',
85
- typeSymbol: '@deepseek-ai/dsh-llm-billing/types#DeepSeekSessionSpend',
86
- schema: _deepseek_ai_dsh_llm_billing_billing_getSessionSpend_result$schema,
86
+ typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekSessionSpend',
87
+ schema: _rayadesu_dsh_llm_billing_billing_getSessionSpend_result$schema,
87
88
  },
88
- sourceLocation: {"file":"packages/llm/llm-billing/src/balance.ts","line":149,"column":3},
89
+ sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":154,"column":3},
89
90
  },
90
91
  {
91
- id: '@deepseek-ai/dsh-llm-billing#billing/getTodaySpend',
92
+ id: '@rayadesu/dsh-llm-billing#billing/getTodaySpend',
92
93
  service: 'billing',
93
94
  namespace: 'billing',
94
95
  method: 'getTodaySpend',
95
96
  invocation: { kind: 'direct' },
96
97
  parameters: [
98
+ {
99
+ name: 'force',
100
+ wire: 'force',
101
+ source: 'json',
102
+ acceptsUndefined: true,
103
+ codec: {
104
+ mode: 'strict',
105
+ typeSymbol: '@rayadesu/dsh-llm-billing#billing/getTodaySpend:force',
106
+ schema: _rayadesu_dsh_llm_billing_billing_getTodaySpend_parameter_0$schema,
107
+ },
108
+ },
97
109
  ],
98
110
  result: {
99
111
  mode: 'strict',
100
- typeSymbol: '@deepseek-ai/dsh-llm-billing/types#DeepSeekTodaySpend',
101
- schema: _deepseek_ai_dsh_llm_billing_billing_getTodaySpend_result$schema,
112
+ typeSymbol: '@rayadesu/dsh-llm-billing/types#DeepSeekTodaySpend',
113
+ schema: _rayadesu_dsh_llm_billing_billing_getTodaySpend_result$schema,
102
114
  },
103
- sourceLocation: {"file":"packages/llm/llm-billing/src/balance.ts","line":159,"column":3},
115
+ sourceLocation: {"file":"packages/llm-billing/src/balance.ts","line":167,"column":3},
104
116
  },
105
117
  ],
106
118
  }
@@ -4,7 +4,7 @@
4
4
  * takes an already-resolved endpoint and bearer token so the registering
5
5
  * plugin stays the one owner of credential policy; the gateway carries only a
6
6
  * `fetchBalance` thunk for the same reason.
7
- * @module @deepseek-ai/dsh-llm-billing/balance
7
+ * @module @rayadesu/dsh-llm-billing/balance
8
8
  */
9
9
  import type { Context } from '@deepseek-ai/cordis';
10
10
  import type { SessionId } from '@deepseek-ai/dsh-session';
@@ -32,8 +32,12 @@ export interface DeepSeekBalanceGatewayOptions {
32
32
  fetchBalance: () => Promise<DeepSeekBalance>;
33
33
  /** Compute one session's billed spend through the plugin's resolved facts. */
34
34
  fetchSessionSpend: (sessionId: SessionId) => Promise<DeepSeekSessionSpend>;
35
- /** Compute today's billed spend across every session through the plugin's resolved facts. */
36
- fetchTodaySpend: () => Promise<DeepSeekTodaySpend>;
35
+ /**
36
+ * Compute today's billed spend across every session through the plugin's
37
+ * resolved facts. `force` bypasses the host-side time window (the manual
38
+ * refresh path); a `force` miss still reuses revision-gated increments.
39
+ */
40
+ fetchTodaySpend: (force?: boolean) => Promise<DeepSeekTodaySpend>;
37
41
  }
38
42
  /**
39
43
  * Remote-only service exposing the DeepSeek account balance and session spend.
@@ -55,17 +59,21 @@ export declare class DeepSeekBalanceGateway extends TypertRemoteService {
55
59
  */
56
60
  getBalance(): Promise<DeepSeekBalance>;
57
61
  /**
58
- * Read one session's billed spend, priced per event by its peak/off-peak hour.
62
+ * Read one session's billed spend, priced per event by its Beijing-time
63
+ * peak/off-peak hour and weekday (weekends are always off-peak).
59
64
  * @param sessionId - the session whose spend to compute.
60
65
  * @returns the session's total cost plus one row per priced model.
61
66
  */
62
67
  getSessionSpend(sessionId: SessionId): Promise<DeepSeekSessionSpend>;
63
68
  /**
64
69
  * Read today's billed spend across every session, priced per event by its
65
- * Beijing-time calendar day and peak/off-peak hour.
70
+ * Beijing-time calendar day, hour, and weekday (weekends are always off-peak).
71
+ * @param force - bypass the host-side 60s cache (manual refresh); omitted
72
+ * means a cached read. Remote parameters cannot carry default values, so
73
+ * the thunk receives `undefined` for an omitted argument.
66
74
  * @returns today's total cost plus one row per priced model.
67
75
  */
68
- getTodaySpend(): Promise<DeepSeekTodaySpend>;
76
+ getTodaySpend(force?: boolean): Promise<DeepSeekTodaySpend>;
69
77
  }
70
78
  export default DeepSeekBalanceGateway;
71
79
  //# sourceMappingURL=balance.d.ts.map
@@ -4,7 +4,7 @@
4
4
  * takes an already-resolved endpoint and bearer token so the registering
5
5
  * plugin stays the one owner of credential policy; the gateway carries only a
6
6
  * `fetchBalance` thunk for the same reason.
7
- * @module @deepseek-ai/dsh-llm-billing/balance
7
+ * @module @rayadesu/dsh-llm-billing/balance
8
8
  */
9
9
  var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
10
10
  var useValue = arguments.length > 2;
@@ -165,7 +165,8 @@ let DeepSeekBalanceGateway = (() => {
165
165
  return this.options.fetchBalance();
166
166
  }
167
167
  /**
168
- * Read one session's billed spend, priced per event by its peak/off-peak hour.
168
+ * Read one session's billed spend, priced per event by its Beijing-time
169
+ * peak/off-peak hour and weekday (weekends are always off-peak).
169
170
  * @param sessionId - the session whose spend to compute.
170
171
  * @returns the session's total cost plus one row per priced model.
171
172
  */
@@ -174,11 +175,14 @@ let DeepSeekBalanceGateway = (() => {
174
175
  }
175
176
  /**
176
177
  * Read today's billed spend across every session, priced per event by its
177
- * Beijing-time calendar day and peak/off-peak hour.
178
+ * Beijing-time calendar day, hour, and weekday (weekends are always off-peak).
179
+ * @param force - bypass the host-side 60s cache (manual refresh); omitted
180
+ * means a cached read. Remote parameters cannot carry default values, so
181
+ * the thunk receives `undefined` for an omitted argument.
178
182
  * @returns today's total cost plus one row per priced model.
179
183
  */
180
- getTodaySpend() {
181
- return this.options.fetchTodaySpend();
184
+ getTodaySpend(force) {
185
+ return this.options.fetchTodaySpend(force ?? false);
182
186
  }
183
187
  };
184
188
  })();
@@ -3,7 +3,13 @@
3
3
  * pricing. Pure functions over session events and the pricing table, so the
4
4
  * Remote gateway stays transport-free and the whole spend is testable without
5
5
  * a key.
6
- * @module @deepseek-ai/dsh-llm-billing/billing
6
+ *
7
+ * The per-event pricing lives in {@link priceEvent}, the one shared fold
8
+ * primitive: the events-scan paths ({@link computeSessionSpend},
9
+ * {@link computeTodaySpend}) and the session-projection unit
10
+ * (`billingTodaySpend` in projection.ts) all fold the same contribution, so a
11
+ * pricing-table change cannot drift one path from the others.
12
+ * @module @rayadesu/dsh-llm-billing/billing
7
13
  */
8
14
  import type { SessionEvent } from '@deepseek-ai/dsh-session';
9
15
  import type { DeepSeekSessionSpend, DeepSeekTodaySpend } from './types.ts';
@@ -32,7 +38,7 @@ export interface BillingConfigModel {
32
38
  /** Off-peak price. */
33
39
  offPeak: DeepSeekTokenPrice;
34
40
  }
35
- /** One peak-hour window on a 24h Beijing-time clock. */
41
+ /** One peak-hour window on a 24h Beijing-time clock, applied weekdays only. */
36
42
  export interface PeakHourWindow {
37
43
  /** Inclusive start hour, `0`–`23`. */
38
44
  start: number;
@@ -41,12 +47,19 @@ export interface PeakHourWindow {
41
47
  }
42
48
  /** Optional billing configuration; omission uses the published defaults. */
43
49
  export interface BillingConfig {
44
- /** Peak-hour windows in Beijing time. */
50
+ /**
51
+ * Peak-hour windows in Beijing time, applied on weekdays (Monday–Friday)
52
+ * only; weekends (Saturday and Sunday) are always off-peak.
53
+ */
45
54
  peakHours?: PeakHourWindow[];
46
- /** Per-model pricing rows; omission uses the V4 Flash and V4 Pro defaults. */
55
+ /** Per-model pricing rows; omission uses the V4 Flash, V4 Pro, and V4 Flash Vision defaults. */
47
56
  models?: BillingConfigModel[];
48
57
  }
49
- /** Published peak-hour windows (Beijing time): 09:00–12:00 and 14:00–18:00. */
58
+ /**
59
+ * Published peak-hour windows (Beijing time): 09:00–12:00 and 14:00–18:00,
60
+ * applied on weekdays (Monday–Friday) only — weekends are always off-peak
61
+ * (effective 2026-08-23).
62
+ */
50
63
  export declare const DEFAULT_PEAK_HOURS: {
51
64
  start: number;
52
65
  end: number;
@@ -71,13 +84,81 @@ export interface ResolvedBilling {
71
84
  * @returns the resolved table and peak-hour windows.
72
85
  */
73
86
  export declare function resolveBilling(config: BillingConfig | undefined): ResolvedBilling;
87
+ /** The Beijing (Asia/Shanghai, UTC+8, no DST) calendar-day key of a timestamp. */
88
+ export declare function beijingDayKey(now: Date): string;
74
89
  /**
75
- * Whether a timestamp falls inside any peak-hour window (Beijing time).
90
+ * Whether a timestamp falls inside any peak-hour window (Beijing time,
91
+ * weekdays Monday–Friday only). Weekends (Saturday and Sunday) are always
92
+ * off-peak, matching the published peak-hours rule.
76
93
  * @param billing - resolved pricing with peak-hour windows.
77
94
  * @param now - the moment to classify.
78
- * @returns true during peak hours.
95
+ * @returns true during a weekday peak hour.
79
96
  */
80
97
  export declare function isPeak(billing: ResolvedBilling, now: Date): boolean;
98
+ /**
99
+ * One priced billed event's contribution: the model row plus the Beijing
100
+ * calendar day its timestamp falls on. `undefined` when the event carries no
101
+ * priced usage (not an `assistant/message`, no usage report, or a model
102
+ * without a pricing row).
103
+ */
104
+ export interface BillingEventContribution {
105
+ /** Beijing-time calendar-day key of the event's timestamp. */
106
+ dayKey: string;
107
+ /** Wire model id, e.g. `deepseek-v4-flash`. */
108
+ model: string;
109
+ /** Selector label for the model. */
110
+ displayName: string;
111
+ /** Billed cost in CNY (peak plus off-peak portions). */
112
+ cost: number;
113
+ /** Cost portion billed at peak rates. */
114
+ peakCost: number;
115
+ /** Cost portion billed at off-peak rates. */
116
+ offPeakCost: number;
117
+ /** Cache-hit input tokens billed at the hit rate. */
118
+ cacheHitInputTokens: number;
119
+ /** Cache-miss input tokens (uncached input plus cache writes), billed at the miss rate. */
120
+ cacheMissInputTokens: number;
121
+ /** Output tokens (reasoning included), billed at the output rate. */
122
+ outputTokens: number;
123
+ /** Billed cost of cache-hit input tokens in CNY. */
124
+ cacheHitInputCost: number;
125
+ /** Billed cost of cache-miss input tokens (uncached input plus cache writes) in CNY. */
126
+ cacheMissInputCost: number;
127
+ /** Billed cost of output tokens (reasoning included) in CNY. */
128
+ outputCost: number;
129
+ }
130
+ /**
131
+ * Price one event at the official per-model rates, applying the peak/off-peak
132
+ * table by its Beijing-time hour and weekday (peak windows apply Monday–Friday
133
+ * only; weekends are off-peak). Each `assistant/message` event with usage
134
+ * contributes cache-hit input, cache-miss input (uncached input plus cache
135
+ * writes), and output (reasoning included) tokens at the rate of its own
136
+ * timestamp; a model with usage but no pricing row contributes nothing (the
137
+ * published table prices only the two V4 rows).
138
+ * @param event - the event to price.
139
+ * @param billing - resolved pricing with peak-hour windows.
140
+ * @param names - model id → display label.
141
+ * @returns the priced contribution, or `undefined` when the event has no priced usage.
142
+ */
143
+ export declare function priceEvent(event: SessionEvent, billing: ResolvedBilling, names: ReadonlyMap<string, string>): BillingEventContribution | undefined;
144
+ /** A spend with no priced usage. */
145
+ export declare function emptyTodaySpend(): DeepSeekTodaySpend;
146
+ /**
147
+ * Merge one priced event's contribution into an accumulator spend (pure:
148
+ * returns a new spend, never mutates its input).
149
+ * @param spend - the accumulator (per session and day, or across sessions).
150
+ * @param priced - the priced contribution to add.
151
+ * @returns the merged spend.
152
+ */
153
+ export declare function addEventContribution(spend: DeepSeekTodaySpend, priced: BillingEventContribution): DeepSeekTodaySpend;
154
+ /**
155
+ * Sum two spends (per session and day, or across sessions) into one (pure:
156
+ * returns a new spend, never mutates its inputs).
157
+ * @param target - the accumulator spend.
158
+ * @param source - the spend to add.
159
+ * @returns the summed spend.
160
+ */
161
+ export declare function mergeTodaySpend(target: DeepSeekTodaySpend, source: DeepSeekTodaySpend): DeepSeekTodaySpend;
81
162
  /**
82
163
  * Price one session's complete event log at the official per-model rates.
83
164
  * @param events - one session's complete event log.