ccusage 15.9.6 → 15.9.8

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.
@@ -761,7 +761,7 @@ function _getDefaultLogLevel() {
761
761
  return g ? LogLevels.debug : R ? LogLevels.warn : LogLevels.info;
762
762
  }
763
763
  const consola = createConsola$1();
764
- var name = "ccusage", version = "15.9.6", description = "Usage analysis tool for Claude Code";
764
+ var name = "ccusage", version = "15.9.8", description = "Usage analysis tool for Claude Code";
765
765
  const logger = consola.withTag(name);
766
766
  if (process$1.env.LOG_LEVEL != null) {
767
767
  const level = Number.parseInt(process$1.env.LOG_LEVEL, 10);
package/dist/logger.js CHANGED
@@ -1,2 +1,2 @@
1
- import { log, logger } from "./logger-B42xzUl2.js";
1
+ import { log, logger } from "./logger-OEFb8rpr.js";
2
2
  export { log, logger };
@@ -1,9 +1,9 @@
1
- import { __commonJSMin, __toESM, require_usingCtx } from "./pricing-fetcher-BtJtc54j.js";
1
+ import { __commonJSMin, __toESM, require_usingCtx } from "./pricing-fetcher-s0HJ9Lpa.js";
2
2
  import { getTotalTokens } from "./_token-utils-WjkbrjKv.js";
3
- import { ZodFirstPartyTypeKind, ZodOptional, ZodType, arrayType, booleanType, discriminatedUnionType, enumType, filterDateSchema, literalType, numberType, objectType, optionalType, recordType, stringType, unionType, unknownType } from "./_types-C0oFKDO-.js";
3
+ import { ZodFirstPartyTypeKind, ZodOptional, ZodType, arrayType, booleanType, discriminatedUnionType, enumType, filterDateSchema, literalType, numberType, objectType, optionalType, recordType, stringType, unionType, unknownType } from "./_types-BbEk8t2a.js";
4
4
  import { calculateTotals, createTotalsObject } from "./calculate-cost-BDqO4yWA.js";
5
- import { getClaudePaths, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData } from "./data-loader-C_o-3Ju1.js";
6
- import { name, version } from "./logger-B42xzUl2.js";
5
+ import { getClaudePaths, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData } from "./data-loader-DGO3W7OE.js";
6
+ import { name, version } from "./logger-OEFb8rpr.js";
7
7
  import process from "node:process";
8
8
  const LATEST_PROTOCOL_VERSION = "2025-06-18", SUPPORTED_PROTOCOL_VERSIONS = [
9
9
  LATEST_PROTOCOL_VERSION,
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import "./pricing-fetcher-B5m_kEpz.js";
2
- import { LoadOptions } from "./data-loader-BPepPoPg.js";
1
+ import "./pricing-fetcher-BgDfBZ05.js";
2
+ import { LoadOptions } from "./data-loader-BJnD_oR3.js";
3
3
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
4
  import { Hono } from "hono/tiny";
5
5
 
package/dist/mcp.js CHANGED
@@ -1,8 +1,8 @@
1
- import "./pricing-fetcher-BtJtc54j.js";
1
+ import "./pricing-fetcher-s0HJ9Lpa.js";
2
2
  import "./_token-utils-WjkbrjKv.js";
3
- import "./_types-C0oFKDO-.js";
3
+ import "./_types-BbEk8t2a.js";
4
4
  import "./calculate-cost-BDqO4yWA.js";
5
- import "./data-loader-C_o-3Ju1.js";
6
- import "./logger-B42xzUl2.js";
7
- import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-DsGPnOCJ.js";
5
+ import "./data-loader-DGO3W7OE.js";
6
+ import "./logger-OEFb8rpr.js";
7
+ import { createMcpHttpApp, createMcpServer, startMcpServerStdio } from "./mcp-BNRa354P.js";
8
8
  export { createMcpHttpApp, createMcpServer, startMcpServerStdio };
@@ -107,16 +107,26 @@ declare const modelPricingSchema: z.ZodObject<{
107
107
  output_cost_per_token: z.ZodOptional<z.ZodNumber>;
108
108
  cache_creation_input_token_cost: z.ZodOptional<z.ZodNumber>;
109
109
  cache_read_input_token_cost: z.ZodOptional<z.ZodNumber>;
110
+ // Context window limits from LiteLLM data
111
+ max_tokens: z.ZodOptional<z.ZodNumber>;
112
+ max_input_tokens: z.ZodOptional<z.ZodNumber>;
113
+ max_output_tokens: z.ZodOptional<z.ZodNumber>;
110
114
  }, "strip", z.ZodTypeAny, {
111
115
  input_cost_per_token?: number | undefined;
112
116
  output_cost_per_token?: number | undefined;
113
117
  cache_creation_input_token_cost?: number | undefined;
114
118
  cache_read_input_token_cost?: number | undefined;
119
+ max_tokens?: number | undefined;
120
+ max_input_tokens?: number | undefined;
121
+ max_output_tokens?: number | undefined;
115
122
  }, {
116
123
  input_cost_per_token?: number | undefined;
117
124
  output_cost_per_token?: number | undefined;
118
125
  cache_creation_input_token_cost?: number | undefined;
119
126
  cache_read_input_token_cost?: number | undefined;
127
+ max_tokens?: number | undefined;
128
+ max_input_tokens?: number | undefined;
129
+ max_output_tokens?: number | undefined;
120
130
  }>;
121
131
  /**
122
132
  * Type definition for model pricing information
@@ -166,6 +176,12 @@ declare class PricingFetcher implements Disposable {
166
176
  * @returns Model pricing information or null if not found
167
177
  */
168
178
  getModelPricing(modelName: string): Result.ResultAsync<ModelPricing | null, Error>;
179
+ /**
180
+ * Gets context window limit for a specific model from LiteLLM data
181
+ * @param modelName - The model name to get context limit for
182
+ * @returns The context limit in tokens, or null if not found
183
+ */
184
+ getModelContextLimit(modelName: string): Result.ResultAsync<number | null, Error>;
169
185
  /**
170
186
  * Calculates the cost for given token usage and model
171
187
  * @param tokens - Token usage breakdown
@@ -1,5 +1,5 @@
1
- import { modelPricingSchema } from "./_types-C0oFKDO-.js";
2
- import { logger } from "./logger-B42xzUl2.js";
1
+ import { modelPricingSchema } from "./_types-BbEk8t2a.js";
2
+ import { logger } from "./logger-OEFb8rpr.js";
3
3
  import { createRequire } from "node:module";
4
4
  import path from "node:path";
5
5
  import F, { homedir } from "node:os";
@@ -96,7 +96,7 @@ if (xdgConfig) xdgConfigDirectories.unshift(xdgConfig);
96
96
  const LITELLM_PRICING_URL = "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json", DEFAULT_RECENT_DAYS = 3, BLOCKS_WARNING_THRESHOLD = .8, BLOCKS_COMPACT_WIDTH_THRESHOLD = 120, BLOCKS_DEFAULT_TERMINAL_WIDTH = 120, DEBUG_MATCH_THRESHOLD_PERCENT = .1, USER_HOME_DIR = homedir(), XDG_CONFIG_DIR = xdgConfig ?? `${USER_HOME_DIR}/.config`, DEFAULT_CLAUDE_CODE_PATH = ".claude", DEFAULT_CLAUDE_CONFIG_PATH = `${XDG_CONFIG_DIR}/claude`, CLAUDE_CONFIG_DIR_ENV = "CLAUDE_CONFIG_DIR", PROJECT_ALIASES_ENV = "CCUSAGE_PROJECT_ALIASES", CLAUDE_PROJECTS_DIR_NAME = "projects", USAGE_DATA_GLOB_PATTERN = "**/*.jsonl", MCP_DEFAULT_PORT = 8080, DEFAULT_REFRESH_INTERVAL_SECONDS = 1, MIN_REFRESH_INTERVAL_SECONDS = 1, MAX_REFRESH_INTERVAL_SECONDS = 60, MIN_RENDER_INTERVAL_MS = 16, BURN_RATE_THRESHOLDS = {
97
97
  HIGH: 1e3,
98
98
  MODERATE: 500
99
- }, CONTEXT_LIMIT = 2e5, DEFAULT_CONTEXT_USAGE_THRESHOLDS = {
99
+ }, DEFAULT_CONTEXT_USAGE_THRESHOLDS = {
100
100
  LOW: 50,
101
101
  MEDIUM: 80
102
102
  }, CONTEXT_LOW_THRESHOLD_ENV = "CCUSAGE_CONTEXT_LOW_THRESHOLD", CONTEXT_MEDIUM_THRESHOLD_ENV = "CCUSAGE_CONTEXT_MEDIUM_THRESHOLD", WEEK_DAYS = [
@@ -183,97 +183,145 @@ var require_usingCtx = /* @__PURE__ */ __commonJSMin(((exports, module) => {
183
183
  "input_cost_per_token": 25e-8,
184
184
  "output_cost_per_token": 125e-8,
185
185
  "cache_creation_input_token_cost": 3e-7,
186
- "cache_read_input_token_cost": 3e-8
186
+ "cache_read_input_token_cost": 3e-8,
187
+ "max_tokens": 4096,
188
+ "max_input_tokens": 2e5,
189
+ "max_output_tokens": 4096
187
190
  },
188
191
  "claude-3-5-haiku-20241022": {
189
192
  "input_cost_per_token": 8e-7,
190
193
  "output_cost_per_token": 4e-6,
191
194
  "cache_creation_input_token_cost": 1e-6,
192
- "cache_read_input_token_cost": 8e-8
195
+ "cache_read_input_token_cost": 8e-8,
196
+ "max_tokens": 8192,
197
+ "max_input_tokens": 2e5,
198
+ "max_output_tokens": 8192
193
199
  },
194
200
  "claude-3-5-haiku-latest": {
195
201
  "input_cost_per_token": 1e-6,
196
202
  "output_cost_per_token": 5e-6,
197
203
  "cache_creation_input_token_cost": 125e-8,
198
- "cache_read_input_token_cost": 1e-7
204
+ "cache_read_input_token_cost": 1e-7,
205
+ "max_tokens": 8192,
206
+ "max_input_tokens": 2e5,
207
+ "max_output_tokens": 8192
199
208
  },
200
209
  "claude-3-opus-latest": {
201
210
  "input_cost_per_token": 15e-6,
202
211
  "output_cost_per_token": 75e-6,
203
212
  "cache_creation_input_token_cost": 1875e-8,
204
- "cache_read_input_token_cost": 15e-7
213
+ "cache_read_input_token_cost": 15e-7,
214
+ "max_tokens": 4096,
215
+ "max_input_tokens": 2e5,
216
+ "max_output_tokens": 4096
205
217
  },
206
218
  "claude-3-opus-20240229": {
207
219
  "input_cost_per_token": 15e-6,
208
220
  "output_cost_per_token": 75e-6,
209
221
  "cache_creation_input_token_cost": 1875e-8,
210
- "cache_read_input_token_cost": 15e-7
222
+ "cache_read_input_token_cost": 15e-7,
223
+ "max_tokens": 4096,
224
+ "max_input_tokens": 2e5,
225
+ "max_output_tokens": 4096
211
226
  },
212
227
  "claude-3-5-sonnet-latest": {
213
228
  "input_cost_per_token": 3e-6,
214
229
  "output_cost_per_token": 15e-6,
215
230
  "cache_creation_input_token_cost": 375e-8,
216
- "cache_read_input_token_cost": 3e-7
231
+ "cache_read_input_token_cost": 3e-7,
232
+ "max_tokens": 8192,
233
+ "max_input_tokens": 2e5,
234
+ "max_output_tokens": 8192
217
235
  },
218
236
  "claude-3-5-sonnet-20240620": {
219
237
  "input_cost_per_token": 3e-6,
220
238
  "output_cost_per_token": 15e-6,
221
239
  "cache_creation_input_token_cost": 375e-8,
222
- "cache_read_input_token_cost": 3e-7
240
+ "cache_read_input_token_cost": 3e-7,
241
+ "max_tokens": 8192,
242
+ "max_input_tokens": 2e5,
243
+ "max_output_tokens": 8192
223
244
  },
224
245
  "claude-opus-4-20250514": {
225
246
  "input_cost_per_token": 15e-6,
226
247
  "output_cost_per_token": 75e-6,
227
248
  "cache_creation_input_token_cost": 1875e-8,
228
- "cache_read_input_token_cost": 15e-7
249
+ "cache_read_input_token_cost": 15e-7,
250
+ "max_tokens": 32e3,
251
+ "max_input_tokens": 2e5,
252
+ "max_output_tokens": 32e3
229
253
  },
230
254
  "claude-opus-4-1": {
231
255
  "input_cost_per_token": 15e-6,
232
256
  "output_cost_per_token": 75e-6,
233
257
  "cache_creation_input_token_cost": 1875e-8,
234
- "cache_read_input_token_cost": 15e-7
258
+ "cache_read_input_token_cost": 15e-7,
259
+ "max_tokens": 32e3,
260
+ "max_input_tokens": 2e5,
261
+ "max_output_tokens": 32e3
235
262
  },
236
263
  "claude-opus-4-1-20250805": {
237
264
  "input_cost_per_token": 15e-6,
238
265
  "output_cost_per_token": 75e-6,
239
266
  "cache_creation_input_token_cost": 1875e-8,
240
- "cache_read_input_token_cost": 15e-7
267
+ "cache_read_input_token_cost": 15e-7,
268
+ "max_tokens": 32e3,
269
+ "max_input_tokens": 2e5,
270
+ "max_output_tokens": 32e3
241
271
  },
242
272
  "claude-sonnet-4-20250514": {
243
273
  "input_cost_per_token": 3e-6,
244
274
  "output_cost_per_token": 15e-6,
245
275
  "cache_creation_input_token_cost": 375e-8,
246
- "cache_read_input_token_cost": 3e-7
276
+ "cache_read_input_token_cost": 3e-7,
277
+ "max_tokens": 64e3,
278
+ "max_input_tokens": 2e5,
279
+ "max_output_tokens": 64e3
247
280
  },
248
281
  "claude-4-opus-20250514": {
249
282
  "input_cost_per_token": 15e-6,
250
283
  "output_cost_per_token": 75e-6,
251
284
  "cache_creation_input_token_cost": 1875e-8,
252
- "cache_read_input_token_cost": 15e-7
285
+ "cache_read_input_token_cost": 15e-7,
286
+ "max_tokens": 32e3,
287
+ "max_input_tokens": 2e5,
288
+ "max_output_tokens": 32e3
253
289
  },
254
290
  "claude-4-sonnet-20250514": {
255
291
  "input_cost_per_token": 3e-6,
256
292
  "output_cost_per_token": 15e-6,
257
293
  "cache_creation_input_token_cost": 375e-8,
258
- "cache_read_input_token_cost": 3e-7
294
+ "cache_read_input_token_cost": 3e-7,
295
+ "max_tokens": 64e3,
296
+ "max_input_tokens": 2e5,
297
+ "max_output_tokens": 64e3
259
298
  },
260
299
  "claude-3-7-sonnet-latest": {
261
300
  "input_cost_per_token": 3e-6,
262
301
  "output_cost_per_token": 15e-6,
263
302
  "cache_creation_input_token_cost": 375e-8,
264
- "cache_read_input_token_cost": 3e-7
303
+ "cache_read_input_token_cost": 3e-7,
304
+ "max_tokens": 128e3,
305
+ "max_input_tokens": 2e5,
306
+ "max_output_tokens": 128e3
265
307
  },
266
308
  "claude-3-7-sonnet-20250219": {
267
309
  "input_cost_per_token": 3e-6,
268
310
  "output_cost_per_token": 15e-6,
269
311
  "cache_creation_input_token_cost": 375e-8,
270
- "cache_read_input_token_cost": 3e-7
312
+ "cache_read_input_token_cost": 3e-7,
313
+ "max_tokens": 128e3,
314
+ "max_input_tokens": 2e5,
315
+ "max_output_tokens": 128e3
271
316
  },
272
317
  "claude-3-5-sonnet-20241022": {
273
318
  "input_cost_per_token": 3e-6,
274
319
  "output_cost_per_token": 15e-6,
275
320
  "cache_creation_input_token_cost": 375e-8,
276
- "cache_read_input_token_cost": 3e-7
321
+ "cache_read_input_token_cost": 3e-7,
322
+ "max_tokens": 8192,
323
+ "max_input_tokens": 2e5,
324
+ "max_output_tokens": 8192
277
325
  }
278
326
  }));
279
327
  return this.cachedPricing = pricing, pricing;
@@ -332,6 +380,13 @@ var require_usingCtx = /* @__PURE__ */ __commonJSMin(((exports, module) => {
332
380
  return null;
333
381
  }));
334
382
  }
383
+ async getModelContextLimit(modelName) {
384
+ return pipe(this.getModelPricing(modelName), map((pricing) => {
385
+ if (pricing == null) return null;
386
+ const contextLimit = pricing.max_input_tokens ?? pricing.max_tokens;
387
+ return contextLimit ?? null;
388
+ }));
389
+ }
335
390
  async calculateCostFromTokens(tokens, modelName) {
336
391
  return pipe(this.getModelPricing(modelName), map((pricing) => pricing == null ? 0 : this.calculateCostFromPricing(tokens, pricing)));
337
392
  }
@@ -344,4 +399,4 @@ var require_usingCtx = /* @__PURE__ */ __commonJSMin(((exports, module) => {
344
399
  return cost;
345
400
  }
346
401
  };
347
- export { BLOCKS_COMPACT_WIDTH_THRESHOLD, BLOCKS_DEFAULT_TERMINAL_WIDTH, BLOCKS_WARNING_THRESHOLD, BURN_RATE_THRESHOLDS, CLAUDE_CONFIG_DIR_ENV, CLAUDE_PROJECTS_DIR_NAME, CONTEXT_LIMIT, CONTEXT_LOW_THRESHOLD_ENV, CONTEXT_MEDIUM_THRESHOLD_ENV, DEBUG_MATCH_THRESHOLD_PERCENT, DEFAULT_CLAUDE_CODE_PATH, DEFAULT_CLAUDE_CONFIG_PATH, DEFAULT_CONTEXT_USAGE_THRESHOLDS, DEFAULT_RECENT_DAYS, DEFAULT_REFRESH_INTERVAL_SECONDS, MAX_REFRESH_INTERVAL_SECONDS, MCP_DEFAULT_PORT, MIN_REFRESH_INTERVAL_SECONDS, MIN_RENDER_INTERVAL_MS, PROJECT_ALIASES_ENV, PricingFetcher, USAGE_DATA_GLOB_PATTERN, USER_HOME_DIR, WEEK_DAYS, __commonJSMin, __require, __toESM, inspectError, isFailure, isPromise, map, pipe, require_usingCtx, try_ };
402
+ export { BLOCKS_COMPACT_WIDTH_THRESHOLD, BLOCKS_DEFAULT_TERMINAL_WIDTH, BLOCKS_WARNING_THRESHOLD, BURN_RATE_THRESHOLDS, CLAUDE_CONFIG_DIR_ENV, CLAUDE_PROJECTS_DIR_NAME, CONTEXT_LOW_THRESHOLD_ENV, CONTEXT_MEDIUM_THRESHOLD_ENV, DEBUG_MATCH_THRESHOLD_PERCENT, DEFAULT_CLAUDE_CODE_PATH, DEFAULT_CLAUDE_CONFIG_PATH, DEFAULT_CONTEXT_USAGE_THRESHOLDS, DEFAULT_RECENT_DAYS, DEFAULT_REFRESH_INTERVAL_SECONDS, MAX_REFRESH_INTERVAL_SECONDS, MCP_DEFAULT_PORT, MIN_REFRESH_INTERVAL_SECONDS, MIN_RENDER_INTERVAL_MS, PROJECT_ALIASES_ENV, PricingFetcher, USAGE_DATA_GLOB_PATTERN, USER_HOME_DIR, WEEK_DAYS, __commonJSMin, __require, __toESM, inspectError, isFailure, isPromise, isSuccess, map, pipe, require_usingCtx, succeed, try_ };
@@ -1,2 +1,2 @@
1
- import { PricingFetcher } from "./pricing-fetcher-B5m_kEpz.js";
1
+ import { PricingFetcher } from "./pricing-fetcher-BgDfBZ05.js";
2
2
  export { PricingFetcher };
@@ -1,4 +1,4 @@
1
- import { PricingFetcher } from "./pricing-fetcher-BtJtc54j.js";
2
- import "./_types-C0oFKDO-.js";
3
- import "./logger-B42xzUl2.js";
1
+ import { PricingFetcher } from "./pricing-fetcher-s0HJ9Lpa.js";
2
+ import "./_types-BbEk8t2a.js";
3
+ import "./logger-OEFb8rpr.js";
4
4
  export { PricingFetcher };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccusage",
3
- "version": "15.9.6",
3
+ "version": "15.9.8",
4
4
  "description": "Usage analysis tool for Claude Code",
5
5
  "homepage": "https://github.com/ryoppippi/ccusage#readme",
6
6
  "bugs": {