ccusage 11.0.0 → 11.0.1
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.md +23 -1
- package/dist/{calculate-cost-2IwHSzmi.js → calculate-cost-D3IraeGW.js} +15 -0
- package/dist/calculate-cost.d.ts +26 -2
- package/dist/calculate-cost.js +1 -1
- package/dist/core-eFvU0K4V.js +698 -0
- package/dist/{data-loader-BAoqS297.js → data-loader-BzOeJe6y.js} +397 -222
- package/dist/{data-loader-DPQaq8_n.d.ts → data-loader-dbZm5kOW.d.ts} +116 -25
- package/dist/data-loader.d.ts +3 -3
- package/dist/data-loader.js +4 -4
- package/dist/{debug-DzFJHzM5.js → debug-CjjJciy1.js} +20 -7
- package/dist/debug.d.ts +17 -0
- package/dist/debug.js +4 -4
- package/dist/{effect-WSjEuzC9-DHMVzzyB.js → effect-WSjEuzC9-CZCpOgOT.js} +1 -1
- package/dist/{esm-BU3FhOe-.js → esm-D74K9ESq.js} +1 -1
- package/dist/{index-CISmcbXk-CW1Gj6Ab.js → index-CISmcbXk-DpuCarFe.js} +5 -5
- package/dist/index.js +1994 -51
- package/dist/{logger-D3WD64Tx.js → logger-E_Utl_fr.js} +8 -2
- package/dist/logger.d.ts +9 -4
- package/dist/logger.js +1 -1
- package/dist/{mcp-1J7r1g6-.js → mcp-SPAE-cNK.js} +7 -8
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +6 -6
- package/dist/{pricing-fetcher-D-eJQBEJ.js → pricing-fetcher-BtW4MVG7.js} +159 -4
- package/dist/{pricing-fetcher-BkSZh4lR.d.ts → pricing-fetcher-DHaTs-k2.d.ts} +67 -2
- package/dist/pricing-fetcher.d.ts +1 -1
- package/dist/pricing-fetcher.js +2 -2
- package/dist/{sury-DmrZ3_Oj-Cpjsc2Lm.js → sury-DmrZ3_Oj-Lq7x0IZW.js} +1 -1
- package/dist/valibot-CQk-M5rL-btpzU8Qa.js +10 -0
- package/dist/{zod-Db63SLXj-BIXn64AP.js → zod-Db63SLXj-BqWqpKnQ.js} +3 -3
- package/package.json +1 -2
- package/dist/chunk-BLXvPPr8.js +0 -30
- package/dist/core-DHCbAXJf.js +0 -693
- package/dist/utils.table-USks3NGv.js +0 -1844
- package/dist/utils.table.d.ts +0 -27
- package/dist/utils.table.js +0 -3
- package/dist/valibot-CQk-M5rL-BcaCeUrF.js +0 -10
- /package/dist/{arktype-C-GObzDh-CNoBqQrr.js → arktype-C-GObzDh-Bx7Fdrqj.js} +0 -0
- /package/dist/{dist-BZzwBtZs.js → dist-Cb1UHXV5.js} +0 -0
- /package/dist/{prompt-DtZgx4wU.js → prompt-CUbwSrjo.js} +0 -0
- /package/dist/{types-BlyCnKwN.js → types-5-VF7WcO.js} +0 -0
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { ArraySchema, CostMode, InferOutput, NumberSchema, ObjectSchema, OptionalSchema, PricingFetcher, RegexAction, SchemaWithPipe, SortOrder, StringSchema } from "./pricing-fetcher-
|
|
1
|
+
import { ArraySchema, CostMode, InferOutput, NumberSchema, ObjectSchema, OptionalSchema, PricingFetcher, RegexAction, SchemaWithPipe, SortOrder, StringSchema } from "./pricing-fetcher-DHaTs-k2.js";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/session-blocks.internal.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a single usage data entry loaded from JSONL files
|
|
7
|
+
*/
|
|
4
8
|
type LoadedUsageEntry = {
|
|
5
9
|
timestamp: Date;
|
|
6
10
|
usage: {
|
|
@@ -13,24 +17,33 @@ type LoadedUsageEntry = {
|
|
|
13
17
|
model: string;
|
|
14
18
|
version?: string;
|
|
15
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Aggregated token counts for different token types
|
|
22
|
+
*/
|
|
16
23
|
type TokenCounts = {
|
|
17
24
|
inputTokens: number;
|
|
18
25
|
outputTokens: number;
|
|
19
26
|
cacheCreationInputTokens: number;
|
|
20
27
|
cacheReadInputTokens: number;
|
|
21
28
|
};
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Represents a session block (typically 5-hour billing period) with usage data
|
|
31
|
+
*/
|
|
32
|
+
type SessionBlock = {
|
|
33
|
+
id: string; // ISO string of block start time
|
|
24
34
|
startTime: Date;
|
|
25
|
-
endTime: Date;
|
|
26
|
-
actualEndTime?: Date;
|
|
35
|
+
endTime: Date; // startTime + 5 hours (for normal blocks) or gap end time (for gap blocks)
|
|
36
|
+
actualEndTime?: Date; // Last activity in block
|
|
27
37
|
isActive: boolean;
|
|
28
|
-
isGap?: boolean;
|
|
38
|
+
isGap?: boolean; // True if this is a gap block
|
|
29
39
|
entries: LoadedUsageEntry[];
|
|
30
40
|
tokenCounts: TokenCounts;
|
|
31
41
|
costUSD: number;
|
|
32
42
|
models: string[];
|
|
33
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Represents usage burn rate calculations
|
|
46
|
+
*/
|
|
34
47
|
//#endregion
|
|
35
48
|
//#region src/data-loader.d.ts
|
|
36
49
|
/**
|
|
@@ -38,7 +51,10 @@ type FiveHourBlock = {
|
|
|
38
51
|
* Uses environment variable CLAUDE_CONFIG_DIR if set, otherwise defaults to ~/.claude
|
|
39
52
|
*/
|
|
40
53
|
declare function getDefaultClaudePath(): string;
|
|
41
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Valibot schema for validating Claude usage data from JSONL files
|
|
56
|
+
*/
|
|
57
|
+
declare const usageDataSchema: ObjectSchema<{
|
|
42
58
|
readonly timestamp: StringSchema<undefined>;
|
|
43
59
|
readonly version: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
44
60
|
readonly message: ObjectSchema<{
|
|
@@ -54,8 +70,14 @@ declare const UsageDataSchema: ObjectSchema<{
|
|
|
54
70
|
readonly costUSD: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
55
71
|
readonly requestId: OptionalSchema<StringSchema<undefined>, undefined>;
|
|
56
72
|
}, undefined>;
|
|
57
|
-
|
|
58
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Type definition for Claude usage data entries from JSONL files
|
|
75
|
+
*/
|
|
76
|
+
type UsageData = InferOutput<typeof usageDataSchema>;
|
|
77
|
+
/**
|
|
78
|
+
* Valibot schema for model-specific usage breakdown data
|
|
79
|
+
*/
|
|
80
|
+
declare const modelBreakdownSchema: ObjectSchema<{
|
|
59
81
|
readonly modelName: StringSchema<undefined>;
|
|
60
82
|
readonly inputTokens: NumberSchema<undefined>;
|
|
61
83
|
readonly outputTokens: NumberSchema<undefined>;
|
|
@@ -63,8 +85,14 @@ declare const ModelBreakdownSchema: ObjectSchema<{
|
|
|
63
85
|
readonly cacheReadTokens: NumberSchema<undefined>;
|
|
64
86
|
readonly cost: NumberSchema<undefined>;
|
|
65
87
|
}, undefined>;
|
|
66
|
-
|
|
67
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Type definition for model-specific usage breakdown
|
|
90
|
+
*/
|
|
91
|
+
type ModelBreakdown = InferOutput<typeof modelBreakdownSchema>;
|
|
92
|
+
/**
|
|
93
|
+
* Valibot schema for daily usage aggregation data
|
|
94
|
+
*/
|
|
95
|
+
declare const dailyUsageSchema: ObjectSchema<{
|
|
68
96
|
readonly date: SchemaWithPipe<readonly [StringSchema<undefined>, RegexAction<string, undefined>]>;
|
|
69
97
|
readonly inputTokens: NumberSchema<undefined>;
|
|
70
98
|
readonly outputTokens: NumberSchema<undefined>;
|
|
@@ -81,8 +109,14 @@ declare const DailyUsageSchema: ObjectSchema<{
|
|
|
81
109
|
readonly cost: NumberSchema<undefined>;
|
|
82
110
|
}, undefined>, undefined>;
|
|
83
111
|
}, undefined>;
|
|
84
|
-
|
|
85
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Type definition for daily usage aggregation
|
|
114
|
+
*/
|
|
115
|
+
type DailyUsage = InferOutput<typeof dailyUsageSchema>;
|
|
116
|
+
/**
|
|
117
|
+
* Valibot schema for session-based usage aggregation data
|
|
118
|
+
*/
|
|
119
|
+
declare const sessionUsageSchema: ObjectSchema<{
|
|
86
120
|
readonly sessionId: StringSchema<undefined>;
|
|
87
121
|
readonly projectPath: StringSchema<undefined>;
|
|
88
122
|
readonly inputTokens: NumberSchema<undefined>;
|
|
@@ -102,8 +136,14 @@ declare const SessionUsageSchema: ObjectSchema<{
|
|
|
102
136
|
readonly cost: NumberSchema<undefined>;
|
|
103
137
|
}, undefined>, undefined>;
|
|
104
138
|
}, undefined>;
|
|
105
|
-
|
|
106
|
-
|
|
139
|
+
/**
|
|
140
|
+
* Type definition for session-based usage aggregation
|
|
141
|
+
*/
|
|
142
|
+
type SessionUsage = InferOutput<typeof sessionUsageSchema>;
|
|
143
|
+
/**
|
|
144
|
+
* Valibot schema for monthly usage aggregation data
|
|
145
|
+
*/
|
|
146
|
+
declare const monthlyUsageSchema: ObjectSchema<{
|
|
107
147
|
readonly month: SchemaWithPipe<readonly [StringSchema<undefined>, RegexAction<string, undefined>]>;
|
|
108
148
|
readonly inputTokens: NumberSchema<undefined>;
|
|
109
149
|
readonly outputTokens: NumberSchema<undefined>;
|
|
@@ -120,8 +160,21 @@ declare const MonthlyUsageSchema: ObjectSchema<{
|
|
|
120
160
|
readonly cost: NumberSchema<undefined>;
|
|
121
161
|
}, undefined>, undefined>;
|
|
122
162
|
}, undefined>;
|
|
123
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Type definition for monthly usage aggregation
|
|
165
|
+
*/
|
|
166
|
+
type MonthlyUsage = InferOutput<typeof monthlyUsageSchema>;
|
|
167
|
+
/**
|
|
168
|
+
* Formats a date string to YYYY-MM-DD format
|
|
169
|
+
* @param dateStr - Input date string
|
|
170
|
+
* @returns Formatted date string in YYYY-MM-DD format
|
|
171
|
+
*/
|
|
124
172
|
declare function formatDate(dateStr: string): string;
|
|
173
|
+
/**
|
|
174
|
+
* Formats a date string to compact format with year on first line and month-day on second
|
|
175
|
+
* @param dateStr - Input date string
|
|
176
|
+
* @returns Formatted date string with newline separator (YYYY\nMM-DD)
|
|
177
|
+
*/
|
|
125
178
|
declare function formatDateCompact(dateStr: string): string;
|
|
126
179
|
/**
|
|
127
180
|
* Create a unique identifier for deduplication using message ID and request ID
|
|
@@ -137,20 +190,58 @@ declare function getEarliestTimestamp(filePath: string): Promise<Date | null>;
|
|
|
137
190
|
* Files without valid timestamps are placed at the end
|
|
138
191
|
*/
|
|
139
192
|
declare function sortFilesByTimestamp(files: string[]): Promise<string[]>;
|
|
193
|
+
/**
|
|
194
|
+
* Calculates cost for a single usage data entry based on the specified cost calculation mode
|
|
195
|
+
* @param data - Usage data entry
|
|
196
|
+
* @param mode - Cost calculation mode (auto, calculate, or display)
|
|
197
|
+
* @param fetcher - Pricing fetcher instance for calculating costs from tokens
|
|
198
|
+
* @returns Calculated cost in USD
|
|
199
|
+
*/
|
|
140
200
|
declare function calculateCostForEntry(data: UsageData, mode: CostMode, fetcher: PricingFetcher): Promise<number>;
|
|
201
|
+
/**
|
|
202
|
+
* Date range filter for limiting usage data by date
|
|
203
|
+
*/
|
|
141
204
|
type DateFilter = {
|
|
142
|
-
since?: string;
|
|
143
|
-
until?: string;
|
|
205
|
+
since?: string; // YYYYMMDD format
|
|
206
|
+
until?: string; // YYYYMMDD format
|
|
144
207
|
};
|
|
208
|
+
/**
|
|
209
|
+
* Configuration options for loading usage data
|
|
210
|
+
*/
|
|
145
211
|
type LoadOptions = {
|
|
146
|
-
claudePath?: string;
|
|
147
|
-
mode?: CostMode;
|
|
148
|
-
order?: SortOrder;
|
|
149
|
-
offline?: boolean;
|
|
212
|
+
claudePath?: string; // Custom path to Claude data directory
|
|
213
|
+
mode?: CostMode; // Cost calculation mode
|
|
214
|
+
order?: SortOrder; // Sort order for dates
|
|
215
|
+
offline?: boolean; // Use offline mode for pricing
|
|
216
|
+
sessionDurationHours?: number; // Session block duration in hours
|
|
150
217
|
} & DateFilter;
|
|
218
|
+
/**
|
|
219
|
+
* Loads and aggregates Claude usage data by day
|
|
220
|
+
* Processes all JSONL files in the Claude projects directory and groups usage by date
|
|
221
|
+
* @param options - Optional configuration for loading and filtering data
|
|
222
|
+
* @returns Array of daily usage summaries sorted by date
|
|
223
|
+
*/
|
|
151
224
|
declare function loadDailyUsageData(options?: LoadOptions): Promise<DailyUsage[]>;
|
|
225
|
+
/**
|
|
226
|
+
* Loads and aggregates Claude usage data by session
|
|
227
|
+
* Groups usage data by project path and session ID based on file structure
|
|
228
|
+
* @param options - Optional configuration for loading and filtering data
|
|
229
|
+
* @returns Array of session usage summaries sorted by last activity
|
|
230
|
+
*/
|
|
152
231
|
declare function loadSessionData(options?: LoadOptions): Promise<SessionUsage[]>;
|
|
232
|
+
/**
|
|
233
|
+
* Loads and aggregates Claude usage data by month
|
|
234
|
+
* Uses daily usage data as the source and groups by month
|
|
235
|
+
* @param options - Optional configuration for loading and filtering data
|
|
236
|
+
* @returns Array of monthly usage summaries sorted by month
|
|
237
|
+
*/
|
|
153
238
|
declare function loadMonthlyUsageData(options?: LoadOptions): Promise<MonthlyUsage[]>;
|
|
154
|
-
|
|
239
|
+
/**
|
|
240
|
+
* Loads usage data and organizes it into session blocks (typically 5-hour billing periods)
|
|
241
|
+
* Processes all usage data and groups it into time-based blocks for billing analysis
|
|
242
|
+
* @param options - Optional configuration including session duration and filtering
|
|
243
|
+
* @returns Array of session blocks with usage and cost information
|
|
244
|
+
*/
|
|
245
|
+
declare function loadSessionBlockData(options?: LoadOptions): Promise<SessionBlock[]>;
|
|
155
246
|
//#endregion
|
|
156
|
-
export { DailyUsage,
|
|
247
|
+
export { DailyUsage, DateFilter, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema };
|
package/dist/data-loader.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./pricing-fetcher-
|
|
2
|
-
import { DailyUsage,
|
|
3
|
-
export { DailyUsage,
|
|
1
|
+
import "./pricing-fetcher-DHaTs-k2.js";
|
|
2
|
+
import { DailyUsage, DateFilter, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema } from "./data-loader-dbZm5kOW.js";
|
|
3
|
+
export { DailyUsage, DateFilter, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema };
|
package/dist/data-loader.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./pricing-fetcher-BtW4MVG7.js";
|
|
2
|
+
import { calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema } from "./data-loader-BzOeJe6y.js";
|
|
2
3
|
import "./dist-DCvt9hEv.js";
|
|
3
|
-
import "./logger-
|
|
4
|
-
import "./pricing-fetcher-D-eJQBEJ.js";
|
|
4
|
+
import "./logger-E_Utl_fr.js";
|
|
5
5
|
|
|
6
|
-
export {
|
|
6
|
+
export { calculateCostForEntry, createUniqueHash, dailyUsageSchema, formatDate, formatDateCompact, getDefaultClaudePath, getEarliestTimestamp, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, usageDataSchema };
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import { __toESM } from "./
|
|
2
|
-
import {
|
|
1
|
+
import { PricingFetcher, __toESM, require_usingCtx } from "./pricing-fetcher-BtW4MVG7.js";
|
|
2
|
+
import { glob, usageDataSchema } from "./data-loader-BzOeJe6y.js";
|
|
3
3
|
import { safeParse } from "./dist-DCvt9hEv.js";
|
|
4
|
-
import { logger } from "./logger-
|
|
5
|
-
import { PricingFetcher } from "./pricing-fetcher-D-eJQBEJ.js";
|
|
4
|
+
import { logger } from "./logger-E_Utl_fr.js";
|
|
6
5
|
import { readFile } from "node:fs/promises";
|
|
7
6
|
import { homedir } from "node:os";
|
|
8
7
|
import path from "node:path";
|
|
9
8
|
|
|
10
9
|
//#region src/debug.ts
|
|
11
10
|
var import_usingCtx = __toESM(require_usingCtx(), 1);
|
|
11
|
+
/**
|
|
12
|
+
* Threshold percentage for considering costs as matching (0.1% tolerance)
|
|
13
|
+
*/
|
|
12
14
|
const MATCH_THRESHOLD_PERCENT = .1;
|
|
15
|
+
/**
|
|
16
|
+
* Analyzes usage data to detect pricing mismatches between stored and calculated costs
|
|
17
|
+
* Compares pre-calculated costUSD values with costs calculated from token usage
|
|
18
|
+
* @param claudePath - Optional path to Claude data directory
|
|
19
|
+
* @returns Statistics about pricing mismatches found
|
|
20
|
+
*/
|
|
13
21
|
async function detectMismatches(claudePath) {
|
|
14
22
|
try {
|
|
15
23
|
var _usingCtx = (0, import_usingCtx.default)();
|
|
@@ -33,7 +41,7 @@ async function detectMismatches(claudePath) {
|
|
|
33
41
|
const lines = content.trim().split("\n").filter((line) => line.length > 0);
|
|
34
42
|
for (const line of lines) try {
|
|
35
43
|
const parsed = JSON.parse(line);
|
|
36
|
-
const result = safeParse(
|
|
44
|
+
const result = safeParse(usageDataSchema, parsed);
|
|
37
45
|
if (!result.success) continue;
|
|
38
46
|
const data = result.output;
|
|
39
47
|
stats.totalEntries++;
|
|
@@ -92,6 +100,11 @@ async function detectMismatches(claudePath) {
|
|
|
92
100
|
_usingCtx.d();
|
|
93
101
|
}
|
|
94
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Prints a detailed report of pricing mismatches to the console
|
|
105
|
+
* @param stats - Mismatch statistics to report
|
|
106
|
+
* @param sampleCount - Number of sample discrepancies to show (default: 5)
|
|
107
|
+
*/
|
|
95
108
|
function printMismatchReport(stats, sampleCount = 5) {
|
|
96
109
|
if (stats.entriesWithBoth === 0) {
|
|
97
110
|
logger.info("No pricing data found to analyze.");
|
|
@@ -106,7 +119,7 @@ function printMismatchReport(stats, sampleCount = 5) {
|
|
|
106
119
|
logger.info(`Match rate: ${matchRate.toFixed(2)}%`);
|
|
107
120
|
if (stats.mismatches > 0 && stats.modelStats.size > 0) {
|
|
108
121
|
logger.info("\n=== Model Statistics ===");
|
|
109
|
-
const sortedModels = Array.from(stats.modelStats.entries()).sort((a, b) => b[1].mismatches - a[1].mismatches);
|
|
122
|
+
const sortedModels = Array.from(stats.modelStats.entries()).sort((a$1, b) => b[1].mismatches - a$1[1].mismatches);
|
|
110
123
|
for (const [model, modelStat] of sortedModels) if (modelStat.mismatches > 0) {
|
|
111
124
|
const modelMatchRate = modelStat.matches / modelStat.total * 100;
|
|
112
125
|
logger.info(`${model}:`);
|
|
@@ -118,7 +131,7 @@ function printMismatchReport(stats, sampleCount = 5) {
|
|
|
118
131
|
}
|
|
119
132
|
if (stats.mismatches > 0 && stats.versionStats.size > 0) {
|
|
120
133
|
logger.info("\n=== Version Statistics ===");
|
|
121
|
-
const sortedVersions = Array.from(stats.versionStats.entries()).filter(([_, versionStat]) => versionStat.mismatches > 0).sort((a, b) => b[1].mismatches - a[1].mismatches);
|
|
134
|
+
const sortedVersions = Array.from(stats.versionStats.entries()).filter(([_, versionStat]) => versionStat.mismatches > 0).sort((a$1, b) => b[1].mismatches - a$1[1].mismatches);
|
|
122
135
|
for (const [version, versionStat] of sortedVersions) {
|
|
123
136
|
const versionMatchRate = versionStat.matches / versionStat.total * 100;
|
|
124
137
|
logger.info(`${version}:`);
|
package/dist/debug.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
//#region src/debug.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Represents a pricing discrepancy between original and calculated costs
|
|
4
|
+
*/
|
|
2
5
|
type Discrepancy = {
|
|
3
6
|
file: string;
|
|
4
7
|
timestamp: string;
|
|
@@ -14,6 +17,9 @@ type Discrepancy = {
|
|
|
14
17
|
cache_read_input_tokens?: number;
|
|
15
18
|
};
|
|
16
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Statistics about pricing mismatches across all usage data
|
|
22
|
+
*/
|
|
17
23
|
type MismatchStats = {
|
|
18
24
|
totalEntries: number;
|
|
19
25
|
entriesWithBoth: number;
|
|
@@ -33,7 +39,18 @@ type MismatchStats = {
|
|
|
33
39
|
avgPercentDiff: number;
|
|
34
40
|
}>;
|
|
35
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Analyzes usage data to detect pricing mismatches between stored and calculated costs
|
|
44
|
+
* Compares pre-calculated costUSD values with costs calculated from token usage
|
|
45
|
+
* @param claudePath - Optional path to Claude data directory
|
|
46
|
+
* @returns Statistics about pricing mismatches found
|
|
47
|
+
*/
|
|
36
48
|
declare function detectMismatches(claudePath?: string): Promise<MismatchStats>;
|
|
49
|
+
/**
|
|
50
|
+
* Prints a detailed report of pricing mismatches to the console
|
|
51
|
+
* @param stats - Mismatch statistics to report
|
|
52
|
+
* @param sampleCount - Number of sample discrepancies to show (default: 5)
|
|
53
|
+
*/
|
|
37
54
|
declare function printMismatchReport(stats: MismatchStats, sampleCount?: number): void;
|
|
38
55
|
//#endregion
|
|
39
56
|
export { detectMismatches, printMismatchReport };
|
package/dist/debug.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./
|
|
1
|
+
import "./pricing-fetcher-BtW4MVG7.js";
|
|
2
|
+
import "./data-loader-BzOeJe6y.js";
|
|
2
3
|
import "./dist-DCvt9hEv.js";
|
|
3
|
-
import "./logger-
|
|
4
|
-
import "./
|
|
5
|
-
import { detectMismatches, printMismatchReport } from "./debug-DzFJHzM5.js";
|
|
4
|
+
import "./logger-E_Utl_fr.js";
|
|
5
|
+
import { detectMismatches, printMismatchReport } from "./debug-CjjJciy1.js";
|
|
6
6
|
|
|
7
7
|
export { detectMismatches, printMismatchReport };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ZodFirstPartyTypeKind, ZodOptional } from "./types-
|
|
1
|
+
import { ZodFirstPartyTypeKind, ZodOptional } from "./types-5-VF7WcO.js";
|
|
2
2
|
|
|
3
3
|
//#region node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
4
4
|
const ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
@@ -9,11 +9,11 @@ const tryImport = async (result, name) => {
|
|
|
9
9
|
};
|
|
10
10
|
const getToJsonSchemaFn = async (vendor) => {
|
|
11
11
|
switch (vendor) {
|
|
12
|
-
case "arktype": return import("./arktype-C-GObzDh-
|
|
13
|
-
case "effect": return import("./effect-WSjEuzC9-
|
|
14
|
-
case "sury": return import("./sury-DmrZ3_Oj-
|
|
15
|
-
case "valibot": return import("./valibot-CQk-M5rL-
|
|
16
|
-
case "zod": return import("./zod-Db63SLXj-
|
|
12
|
+
case "arktype": return import("./arktype-C-GObzDh-Bx7Fdrqj.js").then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
|
|
13
|
+
case "effect": return import("./effect-WSjEuzC9-CZCpOgOT.js").then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
|
|
14
|
+
case "sury": return import("./sury-DmrZ3_Oj-Lq7x0IZW.js").then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
|
|
15
|
+
case "valibot": return import("./valibot-CQk-M5rL-btpzU8Qa.js").then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
|
|
16
|
+
case "zod": return import("./zod-Db63SLXj-BqWqpKnQ.js").then(async ({ getToJsonSchemaFn: getToJsonSchemaFn2 }) => getToJsonSchemaFn2());
|
|
17
17
|
default: throw new Error(`xsschema: Unsupported schema vendor "${vendor}". see https://xsai.js.org/docs/packages-top/xsschema#unsupported-schema-vendor`);
|
|
18
18
|
}
|
|
19
19
|
};
|