ccusage 15.2.0 → 15.3.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 +33 -1
- package/dist/_token-utils-WjkbrjKv.js +12 -0
- package/dist/{_types-CmSE0O0q.js → _types-BHFM59hI.js} +3 -3
- package/dist/{calculate-cost-B0RYn0Vm.js → calculate-cost-BDqO4yWA.js} +2 -9
- package/dist/calculate-cost.d.ts +41 -11
- package/dist/calculate-cost.js +3 -2
- package/dist/{data-loader-CzOPffdg.js → data-loader-DqK3z1AK.js} +69 -13
- package/dist/{data-loader-BuHgMcpg.d.ts → data-loader-a9CiVyT5.d.ts} +32 -2
- package/dist/data-loader.d.ts +3 -3
- package/dist/data-loader.js +6 -5
- package/dist/{debug-CCsUo8-n.js → debug-Cby_QhQQ.js} +15 -10
- package/dist/debug.js +6 -5
- package/dist/index.js +75 -34
- package/dist/{logger-CeR-gFvq.js → logger-D7tlrIfv.js} +3 -3
- package/dist/logger.js +1 -1
- package/dist/{mcp-DGCqhgBz.js → mcp-CFT0dcvs.js} +29 -20
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +7 -6
- package/dist/{pricing-fetcher-CrV0acwD.d.ts → pricing-fetcher-B3SvKOod.d.ts} +8 -3
- package/dist/{pricing-fetcher-fT0o6CKK.js → pricing-fetcher-DpoTR8Md.js} +271 -158
- package/dist/pricing-fetcher.d.ts +1 -1
- package/dist/pricing-fetcher.js +3 -3
- package/dist/{prompt-j5YimnLx.js → prompt-DsUFNEY7.js} +2 -2
- package/package.json +5 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { modelPricingSchema } from "./_types-
|
|
2
|
-
import { logger } from "./logger-
|
|
1
|
+
import { modelPricingSchema } from "./_types-BHFM59hI.js";
|
|
2
|
+
import { logger } from "./logger-D7tlrIfv.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import F, { homedir } from "node:os";
|
|
@@ -25,6 +25,107 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
enumerable: true
|
|
26
26
|
}) : target, mod));
|
|
27
27
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
28
|
+
const isFailure = (result) => "Failure" === result.type;
|
|
29
|
+
const isPromise = (value) => "object" == typeof value && null !== value && "then" in value && "function" == typeof value.then && "catch" in value && "function" == typeof value.catch;
|
|
30
|
+
const andThen = (fn) => (result) => {
|
|
31
|
+
const apply = (r) => {
|
|
32
|
+
if (isFailure(r)) return r;
|
|
33
|
+
return fn(r.value);
|
|
34
|
+
};
|
|
35
|
+
return isPromise(result) ? result.then(apply) : apply(result);
|
|
36
|
+
};
|
|
37
|
+
const andThrough = (fn) => (result) => {
|
|
38
|
+
const apply = (r) => {
|
|
39
|
+
if (isFailure(r)) return r;
|
|
40
|
+
const next = fn(r.value);
|
|
41
|
+
if (isPromise(next)) return next.then((n) => {
|
|
42
|
+
if (isFailure(n)) return n;
|
|
43
|
+
return r;
|
|
44
|
+
});
|
|
45
|
+
if (isFailure(next)) return next;
|
|
46
|
+
return r;
|
|
47
|
+
};
|
|
48
|
+
return isPromise(result) ? result.then(apply) : apply(result);
|
|
49
|
+
};
|
|
50
|
+
const succeed = (...args) => {
|
|
51
|
+
const value = args[0];
|
|
52
|
+
if (void 0 === value) return { type: "Success" };
|
|
53
|
+
if (isPromise(value)) return value.then((value$1) => ({
|
|
54
|
+
type: "Success",
|
|
55
|
+
value: value$1
|
|
56
|
+
}));
|
|
57
|
+
return {
|
|
58
|
+
type: "Success",
|
|
59
|
+
value
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
const fail = (...args) => {
|
|
63
|
+
const error = args[0];
|
|
64
|
+
if (void 0 === error) return { type: "Failure" };
|
|
65
|
+
if (isPromise(error)) return error.then((error$1) => ({
|
|
66
|
+
type: "Failure",
|
|
67
|
+
error: error$1
|
|
68
|
+
}));
|
|
69
|
+
return {
|
|
70
|
+
type: "Failure",
|
|
71
|
+
error
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
const isSuccess = (result) => "Success" === result.type;
|
|
75
|
+
const inspect = (fn) => (result) => {
|
|
76
|
+
const apply = (r) => {
|
|
77
|
+
if (isSuccess(r)) fn(r.value);
|
|
78
|
+
return r;
|
|
79
|
+
};
|
|
80
|
+
return isPromise(result) ? result.then(apply) : apply(result);
|
|
81
|
+
};
|
|
82
|
+
const inspectError = (fn) => (result) => {
|
|
83
|
+
const apply = (r) => {
|
|
84
|
+
if (isFailure(r)) fn(r.error);
|
|
85
|
+
return r;
|
|
86
|
+
};
|
|
87
|
+
return isPromise(result) ? result.then(apply) : apply(result);
|
|
88
|
+
};
|
|
89
|
+
const map = (fn) => (result) => {
|
|
90
|
+
const apply = (r) => {
|
|
91
|
+
if (isFailure(r)) return r;
|
|
92
|
+
return succeed(fn(r.value));
|
|
93
|
+
};
|
|
94
|
+
if (isPromise(result)) return result.then(apply);
|
|
95
|
+
return apply(result);
|
|
96
|
+
};
|
|
97
|
+
const orElse = (fn) => (result) => {
|
|
98
|
+
const apply = (r) => {
|
|
99
|
+
if (isSuccess(r)) return r;
|
|
100
|
+
return fn(r.error);
|
|
101
|
+
};
|
|
102
|
+
return isPromise(result) ? result.then(apply) : apply(result);
|
|
103
|
+
};
|
|
104
|
+
const pipe = (value, ...functions) => {
|
|
105
|
+
let next = value;
|
|
106
|
+
for (const func of functions) next = func(next);
|
|
107
|
+
return next;
|
|
108
|
+
};
|
|
109
|
+
const try_ = (options) => {
|
|
110
|
+
if (isPromise(options.try)) {
|
|
111
|
+
if ("safe" in options && options.safe) return succeed(options.try);
|
|
112
|
+
return options.try.then((value) => succeed(value), (error) => fail(options.catch(error)));
|
|
113
|
+
}
|
|
114
|
+
return (...args) => {
|
|
115
|
+
try {
|
|
116
|
+
const output = options.try(...args);
|
|
117
|
+
if (isPromise(output)) {
|
|
118
|
+
const promise = succeed(output);
|
|
119
|
+
if ("safe" in options && options.safe) return promise;
|
|
120
|
+
return promise.catch((error) => fail(options.catch(error)));
|
|
121
|
+
}
|
|
122
|
+
return succeed(output);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
if ("safe" in options && options.safe) throw error;
|
|
125
|
+
return fail(options.catch(error));
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
};
|
|
28
129
|
const homeDirectory = F.homedir();
|
|
29
130
|
const { env } = process;
|
|
30
131
|
const xdgData = env.XDG_DATA_HOME || (homeDirectory ? path.join(homeDirectory, ".local", "share") : void 0);
|
|
@@ -125,6 +226,13 @@ const MAX_REFRESH_INTERVAL_SECONDS = 60;
|
|
|
125
226
|
* Prevents terminal flickering and excessive CPU usage during rapid updates
|
|
126
227
|
*/
|
|
127
228
|
const MIN_RENDER_INTERVAL_MS = 16;
|
|
229
|
+
/**
|
|
230
|
+
* Burn rate thresholds for indicator display (tokens per minute)
|
|
231
|
+
*/
|
|
232
|
+
const BURN_RATE_THRESHOLDS = {
|
|
233
|
+
HIGH: 1e3,
|
|
234
|
+
MODERATE: 500
|
|
235
|
+
};
|
|
128
236
|
var require_usingCtx = __commonJSMin((exports, module) => {
|
|
129
237
|
function _usingCtx() {
|
|
130
238
|
var r = "function" == typeof SuppressedError ? SuppressedError : function(r$1, e$1) {
|
|
@@ -213,116 +321,119 @@ var PricingFetcher = class {
|
|
|
213
321
|
* Loads offline pricing data from pre-fetched cache
|
|
214
322
|
* @returns Map of model names to pricing information
|
|
215
323
|
*/
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
"
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
"
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
"
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
"
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
"
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
"
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
"
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
"
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
"
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
"
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
"
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
"
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
"
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
"
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
"
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
"
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
"
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
"
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
"
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
324
|
+
loadOfflinePricing = try_({
|
|
325
|
+
try: async () => {
|
|
326
|
+
const pricing = new Map(Object.entries({
|
|
327
|
+
"claude-instant-1": {
|
|
328
|
+
"input_cost_per_token": 163e-8,
|
|
329
|
+
"output_cost_per_token": 551e-8
|
|
330
|
+
},
|
|
331
|
+
"claude-instant-1.2": {
|
|
332
|
+
"input_cost_per_token": 163e-9,
|
|
333
|
+
"output_cost_per_token": 551e-9
|
|
334
|
+
},
|
|
335
|
+
"claude-2": {
|
|
336
|
+
"input_cost_per_token": 8e-6,
|
|
337
|
+
"output_cost_per_token": 24e-6
|
|
338
|
+
},
|
|
339
|
+
"claude-2.1": {
|
|
340
|
+
"input_cost_per_token": 8e-6,
|
|
341
|
+
"output_cost_per_token": 24e-6
|
|
342
|
+
},
|
|
343
|
+
"claude-3-haiku-20240307": {
|
|
344
|
+
"input_cost_per_token": 25e-8,
|
|
345
|
+
"output_cost_per_token": 125e-8,
|
|
346
|
+
"cache_creation_input_token_cost": 3e-7,
|
|
347
|
+
"cache_read_input_token_cost": 3e-8
|
|
348
|
+
},
|
|
349
|
+
"claude-3-5-haiku-20241022": {
|
|
350
|
+
"input_cost_per_token": 8e-7,
|
|
351
|
+
"output_cost_per_token": 4e-6,
|
|
352
|
+
"cache_creation_input_token_cost": 1e-6,
|
|
353
|
+
"cache_read_input_token_cost": 8e-8
|
|
354
|
+
},
|
|
355
|
+
"claude-3-5-haiku-latest": {
|
|
356
|
+
"input_cost_per_token": 1e-6,
|
|
357
|
+
"output_cost_per_token": 5e-6,
|
|
358
|
+
"cache_creation_input_token_cost": 125e-8,
|
|
359
|
+
"cache_read_input_token_cost": 1e-7
|
|
360
|
+
},
|
|
361
|
+
"claude-3-opus-latest": {
|
|
362
|
+
"input_cost_per_token": 15e-6,
|
|
363
|
+
"output_cost_per_token": 75e-6,
|
|
364
|
+
"cache_creation_input_token_cost": 1875e-8,
|
|
365
|
+
"cache_read_input_token_cost": 15e-7
|
|
366
|
+
},
|
|
367
|
+
"claude-3-opus-20240229": {
|
|
368
|
+
"input_cost_per_token": 15e-6,
|
|
369
|
+
"output_cost_per_token": 75e-6,
|
|
370
|
+
"cache_creation_input_token_cost": 1875e-8,
|
|
371
|
+
"cache_read_input_token_cost": 15e-7
|
|
372
|
+
},
|
|
373
|
+
"claude-3-sonnet-20240229": {
|
|
374
|
+
"input_cost_per_token": 3e-6,
|
|
375
|
+
"output_cost_per_token": 15e-6
|
|
376
|
+
},
|
|
377
|
+
"claude-3-5-sonnet-latest": {
|
|
378
|
+
"input_cost_per_token": 3e-6,
|
|
379
|
+
"output_cost_per_token": 15e-6,
|
|
380
|
+
"cache_creation_input_token_cost": 375e-8,
|
|
381
|
+
"cache_read_input_token_cost": 3e-7
|
|
382
|
+
},
|
|
383
|
+
"claude-3-5-sonnet-20240620": {
|
|
384
|
+
"input_cost_per_token": 3e-6,
|
|
385
|
+
"output_cost_per_token": 15e-6,
|
|
386
|
+
"cache_creation_input_token_cost": 375e-8,
|
|
387
|
+
"cache_read_input_token_cost": 3e-7
|
|
388
|
+
},
|
|
389
|
+
"claude-opus-4-20250514": {
|
|
390
|
+
"input_cost_per_token": 15e-6,
|
|
391
|
+
"output_cost_per_token": 75e-6,
|
|
392
|
+
"cache_creation_input_token_cost": 1875e-8,
|
|
393
|
+
"cache_read_input_token_cost": 15e-7
|
|
394
|
+
},
|
|
395
|
+
"claude-sonnet-4-20250514": {
|
|
396
|
+
"input_cost_per_token": 3e-6,
|
|
397
|
+
"output_cost_per_token": 15e-6,
|
|
398
|
+
"cache_creation_input_token_cost": 375e-8,
|
|
399
|
+
"cache_read_input_token_cost": 3e-7
|
|
400
|
+
},
|
|
401
|
+
"claude-4-opus-20250514": {
|
|
402
|
+
"input_cost_per_token": 15e-6,
|
|
403
|
+
"output_cost_per_token": 75e-6,
|
|
404
|
+
"cache_creation_input_token_cost": 1875e-8,
|
|
405
|
+
"cache_read_input_token_cost": 15e-7
|
|
406
|
+
},
|
|
407
|
+
"claude-4-sonnet-20250514": {
|
|
408
|
+
"input_cost_per_token": 3e-6,
|
|
409
|
+
"output_cost_per_token": 15e-6,
|
|
410
|
+
"cache_creation_input_token_cost": 375e-8,
|
|
411
|
+
"cache_read_input_token_cost": 3e-7
|
|
412
|
+
},
|
|
413
|
+
"claude-3-7-sonnet-latest": {
|
|
414
|
+
"input_cost_per_token": 3e-6,
|
|
415
|
+
"output_cost_per_token": 15e-6,
|
|
416
|
+
"cache_creation_input_token_cost": 375e-8,
|
|
417
|
+
"cache_read_input_token_cost": 3e-7
|
|
418
|
+
},
|
|
419
|
+
"claude-3-7-sonnet-20250219": {
|
|
420
|
+
"input_cost_per_token": 3e-6,
|
|
421
|
+
"output_cost_per_token": 15e-6,
|
|
422
|
+
"cache_creation_input_token_cost": 375e-8,
|
|
423
|
+
"cache_read_input_token_cost": 3e-7
|
|
424
|
+
},
|
|
425
|
+
"claude-3-5-sonnet-20241022": {
|
|
426
|
+
"input_cost_per_token": 3e-6,
|
|
427
|
+
"output_cost_per_token": 15e-6,
|
|
428
|
+
"cache_creation_input_token_cost": 375e-8,
|
|
429
|
+
"cache_read_input_token_cost": 3e-7
|
|
430
|
+
}
|
|
431
|
+
}));
|
|
432
|
+
this.cachedPricing = pricing;
|
|
433
|
+
return pricing;
|
|
434
|
+
},
|
|
435
|
+
catch: (error) => new Error("Failed to load offline pricing data", { cause: error })
|
|
436
|
+
});
|
|
326
437
|
/**
|
|
327
438
|
* Handles fallback to offline pricing when network fetch fails
|
|
328
439
|
* @param originalError - The original error from the network fetch
|
|
@@ -332,15 +443,12 @@ var PricingFetcher = class {
|
|
|
332
443
|
async handleFallbackToCachedPricing(originalError) {
|
|
333
444
|
logger.warn("Failed to fetch model pricing from LiteLLM, falling back to cached pricing data");
|
|
334
445
|
logger.debug("Fetch error details:", originalError);
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
} catch (fallbackError) {
|
|
340
|
-
logger.error("Failed to load cached pricing data as fallback:", fallbackError);
|
|
446
|
+
return pipe(this.loadOfflinePricing(), inspect((pricing) => {
|
|
447
|
+
logger.info(`Using cached pricing data for ${pricing.size} models`);
|
|
448
|
+
}), inspectError((error) => {
|
|
449
|
+
logger.error("Failed to load cached pricing data as fallback:", error);
|
|
341
450
|
logger.error("Original fetch error:", originalError);
|
|
342
|
-
|
|
343
|
-
}
|
|
451
|
+
}));
|
|
344
452
|
}
|
|
345
453
|
/**
|
|
346
454
|
* Ensures pricing data is loaded, either from cache or by fetching
|
|
@@ -348,24 +456,30 @@ var PricingFetcher = class {
|
|
|
348
456
|
* @returns Map of model names to pricing information
|
|
349
457
|
*/
|
|
350
458
|
async ensurePricingLoaded() {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
try {
|
|
459
|
+
return pipe(this.cachedPricing != null ? succeed(this.cachedPricing) : fail(/* @__PURE__ */ new Error("Cached pricing not available")), orElse(async () => {
|
|
460
|
+
if (this.offline) return this.loadOfflinePricing();
|
|
354
461
|
logger.warn("Fetching latest model pricing from LiteLLM...");
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
462
|
+
return pipe(try_({
|
|
463
|
+
try: fetch(LITELLM_PRICING_URL),
|
|
464
|
+
catch: (error) => new Error("Failed to fetch model pricing from LiteLLM", { cause: error })
|
|
465
|
+
}), andThrough((response) => {
|
|
466
|
+
if (!response.ok) return fail(/* @__PURE__ */ new Error(`Failed to fetch pricing data: ${response.statusText}`));
|
|
467
|
+
return succeed();
|
|
468
|
+
}), andThen(async (response) => try_({
|
|
469
|
+
try: response.json(),
|
|
470
|
+
catch: (error) => new Error("Failed to parse pricing data", { cause: error })
|
|
471
|
+
})), map((data) => {
|
|
472
|
+
const pricing = /* @__PURE__ */ new Map();
|
|
473
|
+
for (const [modelName, modelData] of Object.entries(data)) if (typeof modelData === "object" && modelData !== null) {
|
|
474
|
+
const parsed = modelPricingSchema.safeParse(modelData);
|
|
475
|
+
if (parsed.success) pricing.set(modelName, parsed.data);
|
|
476
|
+
}
|
|
477
|
+
return pricing;
|
|
478
|
+
}), inspect((pricing) => {
|
|
479
|
+
this.cachedPricing = pricing;
|
|
480
|
+
logger.info(`Loaded pricing for ${pricing.size} models`);
|
|
481
|
+
}), orElse(async (error) => this.handleFallbackToCachedPricing(error)));
|
|
482
|
+
}));
|
|
369
483
|
}
|
|
370
484
|
/**
|
|
371
485
|
* Fetches all available model pricing data
|
|
@@ -381,23 +495,24 @@ var PricingFetcher = class {
|
|
|
381
495
|
* @returns Model pricing information or null if not found
|
|
382
496
|
*/
|
|
383
497
|
async getModelPricing(modelName) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
498
|
+
return pipe(this.ensurePricingLoaded(), map((pricing) => {
|
|
499
|
+
const directMatch = pricing.get(modelName);
|
|
500
|
+
if (directMatch != null) return directMatch;
|
|
501
|
+
const variations = [
|
|
502
|
+
modelName,
|
|
503
|
+
`anthropic/${modelName}`,
|
|
504
|
+
`claude-3-5-${modelName}`,
|
|
505
|
+
`claude-3-${modelName}`,
|
|
506
|
+
`claude-${modelName}`
|
|
507
|
+
];
|
|
508
|
+
for (const variant of variations) {
|
|
509
|
+
const match = pricing.get(variant);
|
|
510
|
+
if (match != null) return match;
|
|
511
|
+
}
|
|
512
|
+
const lowerModel = modelName.toLowerCase();
|
|
513
|
+
for (const [key, value] of pricing) if (key.toLowerCase().includes(lowerModel) || lowerModel.includes(key.toLowerCase())) return value;
|
|
514
|
+
return null;
|
|
515
|
+
}));
|
|
401
516
|
}
|
|
402
517
|
/**
|
|
403
518
|
* Calculates the cost for given token usage and model
|
|
@@ -410,9 +525,7 @@ var PricingFetcher = class {
|
|
|
410
525
|
* @returns Total cost in USD
|
|
411
526
|
*/
|
|
412
527
|
async calculateCostFromTokens(tokens, modelName) {
|
|
413
|
-
|
|
414
|
-
if (pricing == null) return 0;
|
|
415
|
-
return this.calculateCostFromPricing(tokens, pricing);
|
|
528
|
+
return pipe(this.getModelPricing(modelName), map((pricing) => pricing == null ? 0 : this.calculateCostFromPricing(tokens, pricing)));
|
|
416
529
|
}
|
|
417
530
|
/**
|
|
418
531
|
* Calculates cost from token usage and pricing information
|
|
@@ -433,4 +546,4 @@ var PricingFetcher = class {
|
|
|
433
546
|
return cost;
|
|
434
547
|
}
|
|
435
548
|
};
|
|
436
|
-
export { BLOCKS_COMPACT_WIDTH_THRESHOLD, BLOCKS_DEFAULT_TERMINAL_WIDTH, BLOCKS_WARNING_THRESHOLD, CLAUDE_CONFIG_DIR_ENV, CLAUDE_PROJECTS_DIR_NAME, DEBUG_MATCH_THRESHOLD_PERCENT, DEFAULT_CLAUDE_CODE_PATH, DEFAULT_CLAUDE_CONFIG_PATH, DEFAULT_RECENT_DAYS, DEFAULT_REFRESH_INTERVAL_SECONDS, MAX_REFRESH_INTERVAL_SECONDS, MCP_DEFAULT_PORT, MIN_REFRESH_INTERVAL_SECONDS, MIN_RENDER_INTERVAL_MS, PricingFetcher, USAGE_DATA_GLOB_PATTERN, USER_HOME_DIR, __commonJSMin, __require, __toESM, require_usingCtx };
|
|
549
|
+
export { BLOCKS_COMPACT_WIDTH_THRESHOLD, BLOCKS_DEFAULT_TERMINAL_WIDTH, BLOCKS_WARNING_THRESHOLD, BURN_RATE_THRESHOLDS, CLAUDE_CONFIG_DIR_ENV, CLAUDE_PROJECTS_DIR_NAME, DEBUG_MATCH_THRESHOLD_PERCENT, DEFAULT_CLAUDE_CODE_PATH, DEFAULT_CLAUDE_CONFIG_PATH, DEFAULT_RECENT_DAYS, DEFAULT_REFRESH_INTERVAL_SECONDS, MAX_REFRESH_INTERVAL_SECONDS, MCP_DEFAULT_PORT, MIN_REFRESH_INTERVAL_SECONDS, MIN_RENDER_INTERVAL_MS, PricingFetcher, USAGE_DATA_GLOB_PATTERN, USER_HOME_DIR, __commonJSMin, __require, __toESM, isFailure, isPromise, require_usingCtx, try_ };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PricingFetcher } from "./pricing-fetcher-
|
|
1
|
+
import { PricingFetcher } from "./pricing-fetcher-B3SvKOod.js";
|
|
2
2
|
export { PricingFetcher };
|
package/dist/pricing-fetcher.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PricingFetcher } from "./pricing-fetcher-
|
|
2
|
-
import "./_types-
|
|
3
|
-
import "./logger-
|
|
1
|
+
import { PricingFetcher } from "./pricing-fetcher-DpoTR8Md.js";
|
|
2
|
+
import "./_types-BHFM59hI.js";
|
|
3
|
+
import "./logger-D7tlrIfv.js";
|
|
4
4
|
export { PricingFetcher };
|
|
@@ -381,7 +381,7 @@ const iD = sD(), v = new Set(["\x1B", ""]), CD = 39, w$1 = "\x07", W$1 = "[",
|
|
|
381
381
|
`)];
|
|
382
382
|
for (const [E, a] of o$1.entries()) {
|
|
383
383
|
if (e$1 += a, v.has(a)) {
|
|
384
|
-
const { groups: B$1 } = new RegExp(`(?:\\${W$1}(?<code>\\d+)m|\\${y}(?<uri>.*)${w$1})`).exec(o$1.slice(E).join("")) || { groups: {} };
|
|
384
|
+
const { groups: B$1 } = (/* @__PURE__ */ new RegExp(`(?:\\${W$1}(?<code>\\d+)m|\\${y}(?<uri>.*)${w$1})`)).exec(o$1.slice(E).join("")) || { groups: {} };
|
|
385
385
|
if (B$1.code !== void 0) {
|
|
386
386
|
const p = Number.parseFloat(B$1.code);
|
|
387
387
|
s = p === CD ? void 0 : p;
|
|
@@ -804,7 +804,7 @@ async function prompt(message, opts = {}) {
|
|
|
804
804
|
if (typeof value !== "symbol" || value.toString() !== "Symbol(clack:cancel)") return value;
|
|
805
805
|
switch (opts.cancel) {
|
|
806
806
|
case "reject": {
|
|
807
|
-
const error = new Error("Prompt cancelled.");
|
|
807
|
+
const error = /* @__PURE__ */ new Error("Prompt cancelled.");
|
|
808
808
|
error.name = "ConsolaPromptCancelledError";
|
|
809
809
|
if (Error.captureStackTrace) Error.captureStackTrace(error, prompt);
|
|
810
810
|
throw error;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ccusage",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.3.1",
|
|
5
5
|
"description": "Usage analysis tool for Claude Code",
|
|
6
6
|
"author": "ryoppippi",
|
|
7
7
|
"license": "MIT",
|
|
@@ -30,5 +30,8 @@
|
|
|
30
30
|
"bin": "./dist/index.js",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist"
|
|
33
|
-
]
|
|
33
|
+
],
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=20.19.3"
|
|
36
|
+
}
|
|
34
37
|
}
|