ccusage 17.1.5 → 17.1.7

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 CHANGED
@@ -6,11 +6,10 @@
6
6
  <p align="center">
7
7
  <a href="https://socket.dev/api/npm/package/ccusage"><img src="https://socket.dev/api/badge/npm/package/ccusage" alt="Socket Badge" /></a>
8
8
  <a href="https://npmjs.com/package/ccusage"><img src="https://img.shields.io/npm/v/ccusage?color=yellow" alt="npm version" /></a>
9
- <a href="https://tanstack.com/stats/npm?packageGroups=%5B%7B%22packages%22:%5B%7B%22name%22:%22ccusage%22%7D%5D%7D%5D&range=30-days&transform=none&binType=daily&showDataMode=all&height=400"><img src="https://img.shields.io/npm/dy/ccusage" alt="NPM Downloads" /></a>
9
+ <a href="https://tanstack.com/stats/npm?packageGroups=%5B%7B%22packages%22:%5B%7B%22name%22:%22ccusage%22%7D%5D%7D%5D&range=30-days&transform=none&binType=daily&showDataMode=all&height=400"><img src="https://img.shields.io/npm/dt/ccusage" alt="NPM Downloads" /></a>
10
10
  <a href="https://packagephobia.com/result?p=ccusage"><img src="https://packagephobia.com/badge?p=ccusage" alt="install size" /></a>
11
11
  <a href="https://deepwiki.com/ryoppippi/ccusage"><img src="https://img.shields.io/badge/DeepWiki-ryoppippi%2Fccusage-blue.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAyCAYAAAAnWDnqAAAAAXNSR0IArs4c6QAAA05JREFUaEPtmUtyEzEQhtWTQyQLHNak2AB7ZnyXZMEjXMGeK/AIi+QuHrMnbChYY7MIh8g01fJoopFb0uhhEqqcbWTp06/uv1saEDv4O3n3dV60RfP947Mm9/SQc0ICFQgzfc4CYZoTPAswgSJCCUJUnAAoRHOAUOcATwbmVLWdGoH//PB8mnKqScAhsD0kYP3j/Yt5LPQe2KvcXmGvRHcDnpxfL2zOYJ1mFwrryWTz0advv1Ut4CJgf5uhDuDj5eUcAUoahrdY/56ebRWeraTjMt/00Sh3UDtjgHtQNHwcRGOC98BJEAEymycmYcWwOprTgcB6VZ5JK5TAJ+fXGLBm3FDAmn6oPPjR4rKCAoJCal2eAiQp2x0vxTPB3ALO2CRkwmDy5WohzBDwSEFKRwPbknEggCPB/imwrycgxX2NzoMCHhPkDwqYMr9tRcP5qNrMZHkVnOjRMWwLCcr8ohBVb1OMjxLwGCvjTikrsBOiA6fNyCrm8V1rP93iVPpwaE+gO0SsWmPiXB+jikdf6SizrT5qKasx5j8ABbHpFTx+vFXp9EnYQmLx02h1QTTrl6eDqxLnGjporxl3NL3agEvXdT0WmEost648sQOYAeJS9Q7bfUVoMGnjo4AZdUMQku50McDcMWcBPvr0SzbTAFDfvJqwLzgxwATnCgnp4wDl6Aa+Ax283gghmj+vj7feE2KBBRMW3FzOpLOADl0Isb5587h/U4gGvkt5v60Z1VLG8BhYjbzRwyQZemwAd6cCR5/XFWLYZRIMpX39AR0tjaGGiGzLVyhse5C9RKC6ai42ppWPKiBagOvaYk8lO7DajerabOZP46Lby5wKjw1HCRx7p9sVMOWGzb/vA1hwiWc6jm3MvQDTogQkiqIhJV0nBQBTU+3okKCFDy9WwferkHjtxib7t3xIUQtHxnIwtx4mpg26/HfwVNVDb4oI9RHmx5WGelRVlrtiw43zboCLaxv46AZeB3IlTkwouebTr1y2NjSpHz68WNFjHvupy3q8TFn3Hos2IAk4Ju5dCo8B3wP7VPr/FGaKiG+T+v+TQqIrOqMTL1VdWV1DdmcbO8KXBz6esmYWYKPwDL5b5FA1a0hwapHiom0r/cKaoqr+27/XcrS5UwSMbQAAAABJRU5ErkJggg==" alt="DeepWiki"></a>
12
12
  <!-- DeepWiki badge generated by https://deepwiki.ryoppippi.com/ -->
13
- <a href="https://claudelog.com/"><img src="https://claudelog.com/img/claude_log_badge.svg" alt="ClaudeLog - A comprehensive knowledge base for Claude." /></a>
14
13
  <a href="https://github.com/hesreallyhim/awesome-claude-code"><img src="https://awesome.re/mentioned-badge.svg" alt="Mentioned in Awesome Claude Code" /></a>
15
14
  </p>
16
15
 
@@ -1,4 +1,4 @@
1
- import { z as getTotalTokens } from "./_types-Ds2jjKYK.js";
1
+ import { z as getTotalTokens } from "./_types-pJw1UnFi.js";
2
2
  function calculateTotals(data) {
3
3
  return data.reduce((acc, item) => ({
4
4
  inputTokens: acc.inputTokens + item.inputTokens,
@@ -1,4 +1,4 @@
1
- import { c as SessionUsage, n as DailyUsage, s as MonthlyUsage, u as WeeklyUsage } from "./data-loader-qw155z_a.js";
1
+ import { c as SessionUsage, n as DailyUsage, s as MonthlyUsage, u as WeeklyUsage } from "./data-loader-fDs6JbEv.js";
2
2
 
3
3
  //#region src/_token-utils.d.ts
4
4
 
@@ -40,6 +40,7 @@ type AnyTokenCounts = TokenCounts | AggregatedTokenCounts;
40
40
  declare function getTotalTokens(tokenCounts: AnyTokenCounts): number;
41
41
  //#endregion
42
42
  //#region src/calculate-cost.d.ts
43
+
43
44
  /**
44
45
  * Alias for AggregatedTokenCounts from shared utilities
45
46
  * @deprecated Use AggregatedTokenCounts from _token-utils.ts instead
@@ -1,3 +1,3 @@
1
- import { z as getTotalTokens } from "./_types-Ds2jjKYK.js";
2
- import { n as createTotalsObject, t as calculateTotals } from "./calculate-cost-BI5czHMM.js";
1
+ import { z as getTotalTokens } from "./_types-pJw1UnFi.js";
2
+ import { n as createTotalsObject, t as calculateTotals } from "./calculate-cost-rv80nQ-a.js";
3
3
  export { calculateTotals, createTotalsObject, getTotalTokens };
@@ -1,5 +1,5 @@
1
- import { A as object, C as boolean, F as string, M as parse$2, P as safeParse, R as union, S as array, _ as requestIdSchema, a as createDailyDate, b as versionSchema, c as createSessionId, f as isoTimestampSchema, g as projectPathSchema, h as monthlyDateSchema, i as createBucket, j as optional, k as number, l as createWeeklyDate, m as modelNameSchema, o as createMonthlyDate, p as messageIdSchema, r as activityDateSchema, s as createProjectPath, u as dailyDateSchema, v as sessionIdSchema, x as weeklyDateSchema, z as getTotalTokens } from "./_types-Ds2jjKYK.js";
2
- import { n as logger } from "./logger-_VjiKYLh.js";
1
+ import { A as object, C as boolean, F as string, M as parse$2, P as safeParse, R as union, S as array, _ as requestIdSchema, a as createDailyDate, b as versionSchema, c as createSessionId, f as isoTimestampSchema, g as projectPathSchema, h as monthlyDateSchema, i as createBucket, j as optional, k as number, l as createWeeklyDate, m as modelNameSchema, o as createMonthlyDate, p as messageIdSchema, r as activityDateSchema, s as createProjectPath, u as dailyDateSchema, v as sessionIdSchema, x as weeklyDateSchema, z as getTotalTokens } from "./_types-pJw1UnFi.js";
2
+ import { n as logger } from "./logger-C7kqABy7.js";
3
3
  import { createRequire } from "node:module";
4
4
  import * as nativeFs from "node:fs";
5
5
  import b, { createReadStream } from "node:fs";
@@ -2884,6 +2884,162 @@ const CLAUDE_PROVIDER_PREFIXES = [
2884
2884
  "openrouter/openai/"
2885
2885
  ];
2886
2886
  const PREFETCHED_CLAUDE_PRICING = {
2887
+ "anthropic.claude-3-5-haiku-20241022-v1:0": {
2888
+ "input_cost_per_token": 8e-7,
2889
+ "output_cost_per_token": 4e-6,
2890
+ "cache_creation_input_token_cost": 1e-6,
2891
+ "cache_read_input_token_cost": 8e-8,
2892
+ "max_tokens": 8192,
2893
+ "max_input_tokens": 2e5,
2894
+ "max_output_tokens": 8192
2895
+ },
2896
+ "anthropic.claude-haiku-4-5-20251001-v1:0": {
2897
+ "input_cost_per_token": 1e-6,
2898
+ "output_cost_per_token": 5e-6,
2899
+ "cache_creation_input_token_cost": 125e-8,
2900
+ "cache_read_input_token_cost": 1e-7,
2901
+ "max_tokens": 64e3,
2902
+ "max_input_tokens": 2e5,
2903
+ "max_output_tokens": 64e3
2904
+ },
2905
+ "anthropic.claude-haiku-4-5@20251001": {
2906
+ "input_cost_per_token": 1e-6,
2907
+ "output_cost_per_token": 5e-6,
2908
+ "cache_creation_input_token_cost": 125e-8,
2909
+ "cache_read_input_token_cost": 1e-7,
2910
+ "max_tokens": 64e3,
2911
+ "max_input_tokens": 2e5,
2912
+ "max_output_tokens": 64e3
2913
+ },
2914
+ "anthropic.claude-3-5-sonnet-20240620-v1:0": {
2915
+ "input_cost_per_token": 3e-6,
2916
+ "output_cost_per_token": 15e-6,
2917
+ "max_tokens": 4096,
2918
+ "max_input_tokens": 2e5,
2919
+ "max_output_tokens": 4096
2920
+ },
2921
+ "anthropic.claude-3-5-sonnet-20241022-v2:0": {
2922
+ "input_cost_per_token": 3e-6,
2923
+ "output_cost_per_token": 15e-6,
2924
+ "cache_creation_input_token_cost": 375e-8,
2925
+ "cache_read_input_token_cost": 3e-7,
2926
+ "max_tokens": 8192,
2927
+ "max_input_tokens": 2e5,
2928
+ "max_output_tokens": 8192
2929
+ },
2930
+ "anthropic.claude-3-7-sonnet-20240620-v1:0": {
2931
+ "input_cost_per_token": 36e-7,
2932
+ "output_cost_per_token": 18e-6,
2933
+ "cache_creation_input_token_cost": 45e-7,
2934
+ "cache_read_input_token_cost": 36e-8,
2935
+ "max_tokens": 8192,
2936
+ "max_input_tokens": 2e5,
2937
+ "max_output_tokens": 8192
2938
+ },
2939
+ "anthropic.claude-3-7-sonnet-20250219-v1:0": {
2940
+ "input_cost_per_token": 3e-6,
2941
+ "output_cost_per_token": 15e-6,
2942
+ "cache_creation_input_token_cost": 375e-8,
2943
+ "cache_read_input_token_cost": 3e-7,
2944
+ "max_tokens": 8192,
2945
+ "max_input_tokens": 2e5,
2946
+ "max_output_tokens": 8192
2947
+ },
2948
+ "anthropic.claude-3-haiku-20240307-v1:0": {
2949
+ "input_cost_per_token": 25e-8,
2950
+ "output_cost_per_token": 125e-8,
2951
+ "max_tokens": 4096,
2952
+ "max_input_tokens": 2e5,
2953
+ "max_output_tokens": 4096
2954
+ },
2955
+ "anthropic.claude-3-opus-20240229-v1:0": {
2956
+ "input_cost_per_token": 15e-6,
2957
+ "output_cost_per_token": 75e-6,
2958
+ "max_tokens": 4096,
2959
+ "max_input_tokens": 2e5,
2960
+ "max_output_tokens": 4096
2961
+ },
2962
+ "anthropic.claude-3-sonnet-20240229-v1:0": {
2963
+ "input_cost_per_token": 3e-6,
2964
+ "output_cost_per_token": 15e-6,
2965
+ "max_tokens": 4096,
2966
+ "max_input_tokens": 2e5,
2967
+ "max_output_tokens": 4096
2968
+ },
2969
+ "anthropic.claude-instant-v1": {
2970
+ "input_cost_per_token": 8e-7,
2971
+ "output_cost_per_token": 24e-7,
2972
+ "max_tokens": 8191,
2973
+ "max_input_tokens": 1e5,
2974
+ "max_output_tokens": 8191
2975
+ },
2976
+ "anthropic.claude-opus-4-1-20250805-v1:0": {
2977
+ "input_cost_per_token": 15e-6,
2978
+ "output_cost_per_token": 75e-6,
2979
+ "cache_creation_input_token_cost": 1875e-8,
2980
+ "cache_read_input_token_cost": 15e-7,
2981
+ "max_tokens": 32e3,
2982
+ "max_input_tokens": 2e5,
2983
+ "max_output_tokens": 32e3
2984
+ },
2985
+ "anthropic.claude-opus-4-20250514-v1:0": {
2986
+ "input_cost_per_token": 15e-6,
2987
+ "output_cost_per_token": 75e-6,
2988
+ "cache_creation_input_token_cost": 1875e-8,
2989
+ "cache_read_input_token_cost": 15e-7,
2990
+ "max_tokens": 32e3,
2991
+ "max_input_tokens": 2e5,
2992
+ "max_output_tokens": 32e3
2993
+ },
2994
+ "anthropic.claude-opus-4-5-20251101-v1:0": {
2995
+ "input_cost_per_token": 5e-6,
2996
+ "output_cost_per_token": 25e-6,
2997
+ "cache_creation_input_token_cost": 625e-8,
2998
+ "cache_read_input_token_cost": 5e-7,
2999
+ "max_tokens": 64e3,
3000
+ "max_input_tokens": 2e5,
3001
+ "max_output_tokens": 64e3
3002
+ },
3003
+ "anthropic.claude-sonnet-4-20250514-v1:0": {
3004
+ "input_cost_per_token": 3e-6,
3005
+ "output_cost_per_token": 15e-6,
3006
+ "cache_creation_input_token_cost": 375e-8,
3007
+ "cache_read_input_token_cost": 3e-7,
3008
+ "max_tokens": 64e3,
3009
+ "max_input_tokens": 1e6,
3010
+ "max_output_tokens": 64e3,
3011
+ "input_cost_per_token_above_200k_tokens": 6e-6,
3012
+ "output_cost_per_token_above_200k_tokens": 225e-7,
3013
+ "cache_creation_input_token_cost_above_200k_tokens": 75e-7,
3014
+ "cache_read_input_token_cost_above_200k_tokens": 6e-7
3015
+ },
3016
+ "anthropic.claude-sonnet-4-5-20250929-v1:0": {
3017
+ "input_cost_per_token": 3e-6,
3018
+ "output_cost_per_token": 15e-6,
3019
+ "cache_creation_input_token_cost": 375e-8,
3020
+ "cache_read_input_token_cost": 3e-7,
3021
+ "max_tokens": 64e3,
3022
+ "max_input_tokens": 2e5,
3023
+ "max_output_tokens": 64e3,
3024
+ "input_cost_per_token_above_200k_tokens": 6e-6,
3025
+ "output_cost_per_token_above_200k_tokens": 225e-7,
3026
+ "cache_creation_input_token_cost_above_200k_tokens": 75e-7,
3027
+ "cache_read_input_token_cost_above_200k_tokens": 6e-7
3028
+ },
3029
+ "anthropic.claude-v1": {
3030
+ "input_cost_per_token": 8e-6,
3031
+ "output_cost_per_token": 24e-6,
3032
+ "max_tokens": 8191,
3033
+ "max_input_tokens": 1e5,
3034
+ "max_output_tokens": 8191
3035
+ },
3036
+ "anthropic.claude-v2:1": {
3037
+ "input_cost_per_token": 8e-6,
3038
+ "output_cost_per_token": 24e-6,
3039
+ "max_tokens": 8191,
3040
+ "max_input_tokens": 1e5,
3041
+ "max_output_tokens": 8191
3042
+ },
2887
3043
  "claude-3-5-haiku-20241022": {
2888
3044
  "input_cost_per_token": 8e-7,
2889
3045
  "output_cost_per_token": 4e-6,
@@ -3040,6 +3196,19 @@ const PREFETCHED_CLAUDE_PRICING = {
3040
3196
  "cache_creation_input_token_cost_above_200k_tokens": 75e-7,
3041
3197
  "cache_read_input_token_cost_above_200k_tokens": 6e-7
3042
3198
  },
3199
+ "claude-sonnet-4-5-20250929-v1:0": {
3200
+ "input_cost_per_token": 3e-6,
3201
+ "output_cost_per_token": 15e-6,
3202
+ "cache_creation_input_token_cost": 375e-8,
3203
+ "cache_read_input_token_cost": 3e-7,
3204
+ "max_tokens": 64e3,
3205
+ "max_input_tokens": 2e5,
3206
+ "max_output_tokens": 64e3,
3207
+ "input_cost_per_token_above_200k_tokens": 6e-6,
3208
+ "output_cost_per_token_above_200k_tokens": 225e-7,
3209
+ "cache_creation_input_token_cost_above_200k_tokens": 75e-7,
3210
+ "cache_read_input_token_cost_above_200k_tokens": 6e-7
3211
+ },
3043
3212
  "claude-opus-4-1": {
3044
3213
  "input_cost_per_token": 15e-6,
3045
3214
  "output_cost_per_token": 75e-6,
@@ -3067,6 +3236,24 @@ const PREFETCHED_CLAUDE_PRICING = {
3067
3236
  "max_input_tokens": 2e5,
3068
3237
  "max_output_tokens": 32e3
3069
3238
  },
3239
+ "claude-opus-4-5-20251101": {
3240
+ "input_cost_per_token": 5e-6,
3241
+ "output_cost_per_token": 25e-6,
3242
+ "cache_creation_input_token_cost": 625e-8,
3243
+ "cache_read_input_token_cost": 5e-7,
3244
+ "max_tokens": 64e3,
3245
+ "max_input_tokens": 2e5,
3246
+ "max_output_tokens": 64e3
3247
+ },
3248
+ "claude-opus-4-5": {
3249
+ "input_cost_per_token": 5e-6,
3250
+ "output_cost_per_token": 25e-6,
3251
+ "cache_creation_input_token_cost": 625e-8,
3252
+ "cache_read_input_token_cost": 5e-7,
3253
+ "max_tokens": 64e3,
3254
+ "max_input_tokens": 2e5,
3255
+ "max_output_tokens": 64e3
3256
+ },
3070
3257
  "claude-sonnet-4-20250514": {
3071
3258
  "input_cost_per_token": 3e-6,
3072
3259
  "output_cost_per_token": 15e-6,
@@ -3668,14 +3855,14 @@ async function loadSessionData(options) {
3668
3855
  }
3669
3856
  }
3670
3857
  async function loadMonthlyUsageData(options) {
3671
- return loadBucketUsageData((data) => createMonthlyDate(data.date.slice(0, 7)), options).then((usages) => usages.map(({ bucket,...rest }) => ({
3858
+ return loadBucketUsageData((data) => createMonthlyDate(data.date.slice(0, 7)), options).then((usages) => usages.map(({ bucket, ...rest }) => ({
3672
3859
  month: parse$2(monthlyDateSchema, bucket),
3673
3860
  ...rest
3674
3861
  })));
3675
3862
  }
3676
3863
  async function loadWeeklyUsageData(options) {
3677
3864
  const startDay = options?.startOfWeek != null ? getDayNumber(options.startOfWeek) : getDayNumber("sunday");
3678
- return loadBucketUsageData((data) => getDateWeek(new Date(data.date), startDay), options).then((usages) => usages.map(({ bucket,...rest }) => ({
3865
+ return loadBucketUsageData((data) => getDateWeek(new Date(data.date), startDay), options).then((usages) => usages.map(({ bucket, ...rest }) => ({
3679
3866
  week: parse$2(weeklyDateSchema, bucket),
3680
3867
  ...rest
3681
3868
  })));