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
|
@@ -949,7 +949,7 @@ function createConsola$1(options = {}) {
|
|
|
949
949
|
defaults: { level },
|
|
950
950
|
stdout: process.stdout,
|
|
951
951
|
stderr: process.stderr,
|
|
952
|
-
prompt: (...args) => import("./prompt-
|
|
952
|
+
prompt: (...args) => import("./prompt-CUbwSrjo.js").then((m) => m.prompt(...args)),
|
|
953
953
|
reporters: options.reporters || [options.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
|
|
954
954
|
...options
|
|
955
955
|
});
|
|
@@ -965,12 +965,18 @@ const consola = createConsola$1();
|
|
|
965
965
|
//#endregion
|
|
966
966
|
//#region package.json
|
|
967
967
|
var name = "ccusage";
|
|
968
|
-
var version = "11.0.
|
|
968
|
+
var version = "11.0.1";
|
|
969
969
|
var description = "Usage analysis tool for Claude Code";
|
|
970
970
|
|
|
971
971
|
//#endregion
|
|
972
972
|
//#region src/logger.ts
|
|
973
|
+
/**
|
|
974
|
+
* Application logger instance with package name tag
|
|
975
|
+
*/
|
|
973
976
|
const logger = consola.withTag(name);
|
|
977
|
+
/**
|
|
978
|
+
* Direct console.log function for cases where logger formatting is not desired
|
|
979
|
+
*/
|
|
974
980
|
const log = console.log;
|
|
975
981
|
|
|
976
982
|
//#endregion
|
package/dist/logger.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { ConsolaInstance } from "consola";
|
|
2
2
|
|
|
3
3
|
//#region src/logger.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Application logger instance with package name tag
|
|
7
|
+
*/
|
|
4
8
|
declare const logger: ConsolaInstance;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Direct console.log function for cases where logger formatting is not desired
|
|
11
|
+
*/
|
|
12
|
+
// eslint-disable-next-line no-console
|
|
13
|
+
declare const log: (message?: any, ...optionalParams: any[]) => void;
|
|
9
14
|
//#endregion
|
|
10
15
|
export { log, logger };
|
package/dist/logger.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { __commonJS, __require, __toESM } from "./
|
|
2
|
-
import { getDefaultClaudePath, loadDailyUsageData,
|
|
1
|
+
import { CostModes, __commonJS, __require, __toESM, dateSchema } from "./pricing-fetcher-BtW4MVG7.js";
|
|
2
|
+
import { getDefaultClaudePath, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData } from "./data-loader-BzOeJe6y.js";
|
|
3
3
|
import { description, literal, object, optional, pipe, union } from "./dist-DCvt9hEv.js";
|
|
4
|
-
import { name, version } from "./logger-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { toJsonSchema } from "./index-CISmcbXk-CW1Gj6Ab.js";
|
|
4
|
+
import { name, version } from "./logger-E_Utl_fr.js";
|
|
5
|
+
import { anyType, arrayType, booleanType, discriminatedUnionType, enumType, literalType, numberType, objectType, optionalType, recordType, stringType, unionType, unknownType } from "./types-5-VF7WcO.js";
|
|
6
|
+
import { toJsonSchema } from "./index-CISmcbXk-DpuCarFe.js";
|
|
8
7
|
import process$1 from "node:process";
|
|
9
8
|
import { EventEmitter } from "events";
|
|
10
9
|
import { randomUUID } from "node:crypto";
|
|
@@ -37594,10 +37593,10 @@ function createMcpServer({ claudePath } = defaultOptions) {
|
|
|
37594
37593
|
});
|
|
37595
37594
|
server.addTool({
|
|
37596
37595
|
name: "blocks",
|
|
37597
|
-
description: "Show usage report grouped by
|
|
37596
|
+
description: "Show usage report grouped by session billing blocks",
|
|
37598
37597
|
parameters: parametersSchema,
|
|
37599
37598
|
execute: async (args) => {
|
|
37600
|
-
const blocksData = await
|
|
37599
|
+
const blocksData = await loadSessionBlockData({
|
|
37601
37600
|
...args,
|
|
37602
37601
|
claudePath
|
|
37603
37602
|
});
|
package/dist/mcp.d.ts
CHANGED
package/dist/mcp.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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 "./
|
|
6
|
-
import
|
|
7
|
-
import "./index-CISmcbXk-CW1Gj6Ab.js";
|
|
4
|
+
import "./logger-E_Utl_fr.js";
|
|
5
|
+
import "./types-5-VF7WcO.js";
|
|
6
|
+
import { createMcpServer } from "./mcp-SPAE-cNK.js";
|
|
7
|
+
import "./index-CISmcbXk-DpuCarFe.js";
|
|
8
8
|
|
|
9
9
|
export { createMcpServer };
|
|
@@ -1,39 +1,164 @@
|
|
|
1
1
|
import { number, object, optional, pipe, regex, safeParse, string } from "./dist-DCvt9hEv.js";
|
|
2
|
-
import { logger } from "./logger-
|
|
2
|
+
import { logger } from "./logger-E_Utl_fr.js";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
3
4
|
|
|
5
|
+
//#region rolldown:runtime
|
|
6
|
+
var __create = Object.create;
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __commonJS = (cb, mod) => function() {
|
|
13
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
17
|
+
key = keys[i];
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
+
get: ((k) => from[k]).bind(null, key),
|
|
20
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
28
|
+
}) : target, mod));
|
|
29
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
4
32
|
//#region src/consts.internal.ts
|
|
33
|
+
/**
|
|
34
|
+
* URL for LiteLLM's model pricing and context window data
|
|
35
|
+
*/
|
|
5
36
|
const LITELLM_PRICING_URL = "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json";
|
|
6
37
|
|
|
7
38
|
//#endregion
|
|
8
39
|
//#region src/types.internal.ts
|
|
40
|
+
/**
|
|
41
|
+
* Valibot schema for validating date strings in YYYYMMDD format
|
|
42
|
+
*/
|
|
9
43
|
const dateSchema = pipe(string(), regex(/^\d{8}$/, "Date must be in YYYYMMDD format"));
|
|
44
|
+
/**
|
|
45
|
+
* Available cost calculation modes
|
|
46
|
+
* - auto: Use pre-calculated costs when available, otherwise calculate from tokens
|
|
47
|
+
* - calculate: Always calculate costs from token counts using model pricing
|
|
48
|
+
* - display: Always use pre-calculated costs, show 0 for missing costs
|
|
49
|
+
*/
|
|
10
50
|
const CostModes = [
|
|
11
51
|
"auto",
|
|
12
52
|
"calculate",
|
|
13
53
|
"display"
|
|
14
54
|
];
|
|
55
|
+
/**
|
|
56
|
+
* Available sort orders for data presentation
|
|
57
|
+
*/
|
|
15
58
|
const SortOrders = ["desc", "asc"];
|
|
16
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Valibot schema for model pricing information from LiteLLM
|
|
61
|
+
*/
|
|
62
|
+
const modelPricingSchema = object({
|
|
17
63
|
input_cost_per_token: optional(number()),
|
|
18
64
|
output_cost_per_token: optional(number()),
|
|
19
65
|
cache_creation_input_token_cost: optional(number()),
|
|
20
66
|
cache_read_input_token_cost: optional(number())
|
|
21
67
|
});
|
|
22
68
|
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region node_modules/rolldown/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js
|
|
71
|
+
var require_usingCtx = __commonJS({ "node_modules/rolldown/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(exports, module) {
|
|
72
|
+
function _usingCtx() {
|
|
73
|
+
var r = "function" == typeof SuppressedError ? SuppressedError : function(r$1, e$1) {
|
|
74
|
+
var n$1 = Error();
|
|
75
|
+
return n$1.name = "SuppressedError", n$1.error = r$1, n$1.suppressed = e$1, n$1;
|
|
76
|
+
}, e = {}, n = [];
|
|
77
|
+
function using(r$1, e$1) {
|
|
78
|
+
if (null != e$1) {
|
|
79
|
+
if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
80
|
+
if (r$1) var o = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
|
|
81
|
+
if (void 0 === o && (o = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$1)) var t = o;
|
|
82
|
+
if ("function" != typeof o) throw new TypeError("Object is not disposable.");
|
|
83
|
+
t && (o = function o$1() {
|
|
84
|
+
try {
|
|
85
|
+
t.call(e$1);
|
|
86
|
+
} catch (r$2) {
|
|
87
|
+
return Promise.reject(r$2);
|
|
88
|
+
}
|
|
89
|
+
}), n.push({
|
|
90
|
+
v: e$1,
|
|
91
|
+
d: o,
|
|
92
|
+
a: r$1
|
|
93
|
+
});
|
|
94
|
+
} else r$1 && n.push({
|
|
95
|
+
d: e$1,
|
|
96
|
+
a: r$1
|
|
97
|
+
});
|
|
98
|
+
return e$1;
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
e,
|
|
102
|
+
u: using.bind(null, !1),
|
|
103
|
+
a: using.bind(null, !0),
|
|
104
|
+
d: function d() {
|
|
105
|
+
var o, t = this.e, s = 0;
|
|
106
|
+
function next() {
|
|
107
|
+
for (; o = n.pop();) try {
|
|
108
|
+
if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next);
|
|
109
|
+
if (o.d) {
|
|
110
|
+
var r$1 = o.d.call(o.v);
|
|
111
|
+
if (o.a) return s |= 2, Promise.resolve(r$1).then(next, err);
|
|
112
|
+
} else s |= 1;
|
|
113
|
+
} catch (r$2) {
|
|
114
|
+
return err(r$2);
|
|
115
|
+
}
|
|
116
|
+
if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve();
|
|
117
|
+
if (t !== e) throw t;
|
|
118
|
+
}
|
|
119
|
+
function err(n$1) {
|
|
120
|
+
return t = t !== e ? new r(n$1, t) : n$1, next();
|
|
121
|
+
}
|
|
122
|
+
return next();
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
127
|
+
} });
|
|
128
|
+
|
|
23
129
|
//#endregion
|
|
24
130
|
//#region src/pricing-fetcher.ts
|
|
131
|
+
var import_usingCtx = __toESM(require_usingCtx(), 1);
|
|
132
|
+
/**
|
|
133
|
+
* Fetches and caches model pricing information from LiteLLM
|
|
134
|
+
* Implements Disposable pattern for automatic resource cleanup
|
|
135
|
+
*/
|
|
25
136
|
var PricingFetcher = class {
|
|
26
137
|
cachedPricing = null;
|
|
27
138
|
offline;
|
|
139
|
+
/**
|
|
140
|
+
* Creates a new PricingFetcher instance
|
|
141
|
+
* @param offline - Whether to use pre-fetched pricing data instead of fetching from API
|
|
142
|
+
*/
|
|
28
143
|
constructor(offline = false) {
|
|
29
144
|
this.offline = offline;
|
|
30
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Implements Disposable interface for automatic cleanup
|
|
148
|
+
*/
|
|
31
149
|
[Symbol.dispose]() {
|
|
32
150
|
this.clearCache();
|
|
33
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Clears the cached pricing data
|
|
154
|
+
*/
|
|
34
155
|
clearCache() {
|
|
35
156
|
this.cachedPricing = null;
|
|
36
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Ensures pricing data is loaded, either from cache or by fetching
|
|
160
|
+
* @returns Map of model names to pricing information
|
|
161
|
+
*/
|
|
37
162
|
async ensurePricingLoaded() {
|
|
38
163
|
if (this.cachedPricing != null) return this.cachedPricing;
|
|
39
164
|
if (this.offline) {
|
|
@@ -153,7 +278,7 @@ var PricingFetcher = class {
|
|
|
153
278
|
const data = await response.json();
|
|
154
279
|
const pricing = /* @__PURE__ */ new Map();
|
|
155
280
|
for (const [modelName, modelData] of Object.entries(data)) if (typeof modelData === "object" && modelData !== null) {
|
|
156
|
-
const parsed = safeParse(
|
|
281
|
+
const parsed = safeParse(modelPricingSchema, modelData);
|
|
157
282
|
if (parsed.success) pricing.set(modelName, parsed.output);
|
|
158
283
|
}
|
|
159
284
|
this.cachedPricing = pricing;
|
|
@@ -164,9 +289,19 @@ var PricingFetcher = class {
|
|
|
164
289
|
throw new Error("Could not fetch model pricing data");
|
|
165
290
|
}
|
|
166
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Fetches all available model pricing data
|
|
294
|
+
* @returns Map of model names to pricing information
|
|
295
|
+
*/
|
|
167
296
|
async fetchModelPricing() {
|
|
168
297
|
return this.ensurePricingLoaded();
|
|
169
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Gets pricing information for a specific model with fallback matching
|
|
301
|
+
* Tries exact match first, then provider prefixes, then partial matches
|
|
302
|
+
* @param modelName - Name of the model to get pricing for
|
|
303
|
+
* @returns Model pricing information or null if not found
|
|
304
|
+
*/
|
|
170
305
|
async getModelPricing(modelName) {
|
|
171
306
|
const pricing = await this.ensurePricingLoaded();
|
|
172
307
|
const directMatch = pricing.get(modelName);
|
|
@@ -186,11 +321,31 @@ var PricingFetcher = class {
|
|
|
186
321
|
for (const [key, value] of pricing) if (key.toLowerCase().includes(lowerModel) || lowerModel.includes(key.toLowerCase())) return value;
|
|
187
322
|
return null;
|
|
188
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* Calculates the cost for given token usage and model
|
|
326
|
+
* @param tokens - Token usage breakdown
|
|
327
|
+
* @param tokens.input_tokens - Number of input tokens
|
|
328
|
+
* @param tokens.output_tokens - Number of output tokens
|
|
329
|
+
* @param tokens.cache_creation_input_tokens - Number of cache creation tokens
|
|
330
|
+
* @param tokens.cache_read_input_tokens - Number of cache read tokens
|
|
331
|
+
* @param modelName - Name of the model used
|
|
332
|
+
* @returns Total cost in USD
|
|
333
|
+
*/
|
|
189
334
|
async calculateCostFromTokens(tokens, modelName) {
|
|
190
335
|
const pricing = await this.getModelPricing(modelName);
|
|
191
336
|
if (pricing == null) return 0;
|
|
192
337
|
return this.calculateCostFromPricing(tokens, pricing);
|
|
193
338
|
}
|
|
339
|
+
/**
|
|
340
|
+
* Calculates cost from token usage and pricing information
|
|
341
|
+
* @param tokens - Token usage breakdown
|
|
342
|
+
* @param tokens.input_tokens - Number of input tokens
|
|
343
|
+
* @param tokens.output_tokens - Number of output tokens
|
|
344
|
+
* @param tokens.cache_creation_input_tokens - Number of cache creation tokens
|
|
345
|
+
* @param tokens.cache_read_input_tokens - Number of cache read tokens
|
|
346
|
+
* @param pricing - Model pricing rates
|
|
347
|
+
* @returns Total cost in USD
|
|
348
|
+
*/
|
|
194
349
|
calculateCostFromPricing(tokens, pricing) {
|
|
195
350
|
let cost = 0;
|
|
196
351
|
if (pricing.input_cost_per_token != null) cost += tokens.input_tokens * pricing.input_cost_per_token;
|
|
@@ -202,4 +357,4 @@ var PricingFetcher = class {
|
|
|
202
357
|
};
|
|
203
358
|
|
|
204
359
|
//#endregion
|
|
205
|
-
export { CostModes, PricingFetcher, SortOrders, dateSchema };
|
|
360
|
+
export { CostModes, PricingFetcher, SortOrders, __commonJS, __require, __toESM, dateSchema, require_usingCtx };
|
|
@@ -1633,34 +1633,99 @@ declare function regex<TInput extends string, const TMessage extends ErrorMessag
|
|
|
1633
1633
|
*/
|
|
1634
1634
|
//#endregion
|
|
1635
1635
|
//#region src/types.internal.d.ts
|
|
1636
|
+
/**
|
|
1637
|
+
* Available cost calculation modes
|
|
1638
|
+
* - auto: Use pre-calculated costs when available, otherwise calculate from tokens
|
|
1639
|
+
* - calculate: Always calculate costs from token counts using model pricing
|
|
1640
|
+
* - display: Always use pre-calculated costs, show 0 for missing costs
|
|
1641
|
+
*/
|
|
1636
1642
|
declare const CostModes: readonly ["auto", "calculate", "display"];
|
|
1643
|
+
/**
|
|
1644
|
+
* Union type for cost calculation modes
|
|
1645
|
+
*/
|
|
1637
1646
|
type CostMode = TupleToUnion<typeof CostModes>;
|
|
1647
|
+
/**
|
|
1648
|
+
* Available sort orders for data presentation
|
|
1649
|
+
*/
|
|
1638
1650
|
declare const SortOrders: readonly ["desc", "asc"];
|
|
1651
|
+
/**
|
|
1652
|
+
* Union type for sort order options
|
|
1653
|
+
*/
|
|
1639
1654
|
type SortOrder = TupleToUnion<typeof SortOrders>;
|
|
1640
|
-
|
|
1655
|
+
/**
|
|
1656
|
+
* Valibot schema for model pricing information from LiteLLM
|
|
1657
|
+
*/
|
|
1658
|
+
declare const modelPricingSchema: ObjectSchema<{
|
|
1641
1659
|
readonly input_cost_per_token: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
1642
1660
|
readonly output_cost_per_token: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
1643
1661
|
readonly cache_creation_input_token_cost: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
1644
1662
|
readonly cache_read_input_token_cost: OptionalSchema<NumberSchema<undefined>, undefined>;
|
|
1645
1663
|
}, undefined>;
|
|
1646
|
-
|
|
1664
|
+
/**
|
|
1665
|
+
* Type definition for model pricing information
|
|
1666
|
+
*/
|
|
1667
|
+
type ModelPricing = InferOutput<typeof modelPricingSchema>;
|
|
1647
1668
|
//#endregion
|
|
1648
1669
|
//#region src/pricing-fetcher.d.ts
|
|
1670
|
+
/**
|
|
1671
|
+
* Fetches and caches model pricing information from LiteLLM
|
|
1672
|
+
* Implements Disposable pattern for automatic resource cleanup
|
|
1673
|
+
*/
|
|
1649
1674
|
declare class PricingFetcher implements Disposable {
|
|
1650
1675
|
private cachedPricing;
|
|
1651
1676
|
private readonly offline;
|
|
1677
|
+
/**
|
|
1678
|
+
* Creates a new PricingFetcher instance
|
|
1679
|
+
* @param offline - Whether to use pre-fetched pricing data instead of fetching from API
|
|
1680
|
+
*/
|
|
1652
1681
|
constructor(offline?: boolean);
|
|
1682
|
+
/**
|
|
1683
|
+
* Implements Disposable interface for automatic cleanup
|
|
1684
|
+
*/
|
|
1653
1685
|
[Symbol.dispose](): void;
|
|
1686
|
+
/**
|
|
1687
|
+
* Clears the cached pricing data
|
|
1688
|
+
*/
|
|
1654
1689
|
clearCache(): void;
|
|
1655
1690
|
private ensurePricingLoaded;
|
|
1691
|
+
/**
|
|
1692
|
+
* Fetches all available model pricing data
|
|
1693
|
+
* @returns Map of model names to pricing information
|
|
1694
|
+
*/
|
|
1656
1695
|
fetchModelPricing(): Promise<Map<string, ModelPricing>>;
|
|
1696
|
+
/**
|
|
1697
|
+
* Gets pricing information for a specific model with fallback matching
|
|
1698
|
+
* Tries exact match first, then provider prefixes, then partial matches
|
|
1699
|
+
* @param modelName - Name of the model to get pricing for
|
|
1700
|
+
* @returns Model pricing information or null if not found
|
|
1701
|
+
*/
|
|
1657
1702
|
getModelPricing(modelName: string): Promise<ModelPricing | null>;
|
|
1703
|
+
/**
|
|
1704
|
+
* Calculates the cost for given token usage and model
|
|
1705
|
+
* @param tokens - Token usage breakdown
|
|
1706
|
+
* @param tokens.input_tokens - Number of input tokens
|
|
1707
|
+
* @param tokens.output_tokens - Number of output tokens
|
|
1708
|
+
* @param tokens.cache_creation_input_tokens - Number of cache creation tokens
|
|
1709
|
+
* @param tokens.cache_read_input_tokens - Number of cache read tokens
|
|
1710
|
+
* @param modelName - Name of the model used
|
|
1711
|
+
* @returns Total cost in USD
|
|
1712
|
+
*/
|
|
1658
1713
|
calculateCostFromTokens(tokens: {
|
|
1659
1714
|
input_tokens: number;
|
|
1660
1715
|
output_tokens: number;
|
|
1661
1716
|
cache_creation_input_tokens?: number;
|
|
1662
1717
|
cache_read_input_tokens?: number;
|
|
1663
1718
|
}, modelName: string): Promise<number>;
|
|
1719
|
+
/**
|
|
1720
|
+
* Calculates cost from token usage and pricing information
|
|
1721
|
+
* @param tokens - Token usage breakdown
|
|
1722
|
+
* @param tokens.input_tokens - Number of input tokens
|
|
1723
|
+
* @param tokens.output_tokens - Number of output tokens
|
|
1724
|
+
* @param tokens.cache_creation_input_tokens - Number of cache creation tokens
|
|
1725
|
+
* @param tokens.cache_read_input_tokens - Number of cache read tokens
|
|
1726
|
+
* @param pricing - Model pricing rates
|
|
1727
|
+
* @returns Total cost in USD
|
|
1728
|
+
*/
|
|
1664
1729
|
calculateCostFromPricing(tokens: {
|
|
1665
1730
|
input_tokens: number;
|
|
1666
1731
|
output_tokens: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PricingFetcher } from "./pricing-fetcher-
|
|
1
|
+
import { PricingFetcher } from "./pricing-fetcher-DHaTs-k2.js";
|
|
2
2
|
export { PricingFetcher };
|
package/dist/pricing-fetcher.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { tryImport } from "./index-CISmcbXk-DpuCarFe.js";
|
|
2
|
+
|
|
3
|
+
//#region node_modules/xsschema/dist/valibot-CQk-M5rL.js
|
|
4
|
+
const getToJsonSchemaFn = async () => {
|
|
5
|
+
const { toJsonSchema } = await tryImport(import("./dist-Cb1UHXV5.js"), "@valibot/to-json-schema");
|
|
6
|
+
return (schema) => toJsonSchema(schema);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { getToJsonSchemaFn };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { missingDependenciesUrl } from "./index-CISmcbXk-
|
|
1
|
+
import { missingDependenciesUrl } from "./index-CISmcbXk-DpuCarFe.js";
|
|
2
2
|
|
|
3
3
|
//#region node_modules/xsschema/dist/zod-Db63SLXj.js
|
|
4
4
|
const getToJsonSchemaFn = async () => {
|
|
@@ -9,13 +9,13 @@ const getToJsonSchemaFn = async () => {
|
|
|
9
9
|
throw new Error(`xsschema: Missing zod v3 dependencies "zod-to-json-schema". see ${missingDependenciesUrl}`);
|
|
10
10
|
};
|
|
11
11
|
try {
|
|
12
|
-
const { toJSONSchema } = await import("./core-
|
|
12
|
+
const { toJSONSchema } = await import("./core-eFvU0K4V.js");
|
|
13
13
|
zodV4toJSONSchema = toJSONSchema;
|
|
14
14
|
} catch (err) {
|
|
15
15
|
if (err instanceof Error) console.error(err.message);
|
|
16
16
|
}
|
|
17
17
|
try {
|
|
18
|
-
const { zodToJsonSchema } = await import("./esm-
|
|
18
|
+
const { zodToJsonSchema } = await import("./esm-D74K9ESq.js");
|
|
19
19
|
zodV3ToJSONSchema = zodToJsonSchema;
|
|
20
20
|
} catch (err) {
|
|
21
21
|
if (err instanceof Error) console.error(err.message);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ccusage",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "11.0.
|
|
4
|
+
"version": "11.0.1",
|
|
5
5
|
"description": "Usage analysis tool for Claude Code",
|
|
6
6
|
"author": "ryoppippi",
|
|
7
7
|
"license": "MIT",
|
|
@@ -22,7 +22,6 @@
|
|
|
22
22
|
"./logger": "./dist/logger.js",
|
|
23
23
|
"./mcp": "./dist/mcp.js",
|
|
24
24
|
"./pricing-fetcher": "./dist/pricing-fetcher.js",
|
|
25
|
-
"./utils.table": "./dist/utils.table.js",
|
|
26
25
|
"./package.json": "./package.json"
|
|
27
26
|
},
|
|
28
27
|
"main": "./dist/index.js",
|
package/dist/chunk-BLXvPPr8.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
//#region rolldown:runtime
|
|
4
|
-
var __create = Object.create;
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __commonJS = (cb, mod) => function() {
|
|
11
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
|
-
key = keys[i];
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
-
get: ((k) => from[k]).bind(null, key),
|
|
18
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
-
value: mod,
|
|
25
|
-
enumerable: true
|
|
26
|
-
}) : target, mod));
|
|
27
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
export { __commonJS, __require, __toESM };
|