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.
- package/dist/{_types-C0oFKDO-.js → _types-BbEk8t2a.js} +4 -1
- package/dist/calculate-cost.d.ts +2 -2
- package/dist/calculate-cost.js +1 -1
- package/dist/{data-loader-BPepPoPg.d.ts → data-loader-BJnD_oR3.d.ts} +2 -2
- package/dist/{data-loader-C_o-3Ju1.js → data-loader-DGO3W7OE.js} +31 -18
- package/dist/data-loader.d.ts +2 -2
- package/dist/data-loader.js +4 -4
- package/dist/{debug-DX6e8anz.js → debug-DobNnsGn.js} +3 -3
- package/dist/debug.js +5 -5
- package/dist/index.js +1280 -207
- package/dist/{logger-B42xzUl2.js → logger-OEFb8rpr.js} +1 -1
- package/dist/logger.js +1 -1
- package/dist/{mcp-DsGPnOCJ.js → mcp-BNRa354P.js} +4 -4
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +5 -5
- package/dist/{pricing-fetcher-B5m_kEpz.d.ts → pricing-fetcher-BgDfBZ05.d.ts} +16 -0
- package/dist/{pricing-fetcher-BtJtc54j.js → pricing-fetcher-s0HJ9Lpa.js} +75 -20
- package/dist/pricing-fetcher.d.ts +1 -1
- package/dist/pricing-fetcher.js +3 -3
- package/package.json +1 -1
|
@@ -3027,7 +3027,10 @@ const CostModes = [
|
|
|
3027
3027
|
input_cost_per_token: numberType().optional(),
|
|
3028
3028
|
output_cost_per_token: numberType().optional(),
|
|
3029
3029
|
cache_creation_input_token_cost: numberType().optional(),
|
|
3030
|
-
cache_read_input_token_cost: numberType().optional()
|
|
3030
|
+
cache_read_input_token_cost: numberType().optional(),
|
|
3031
|
+
max_tokens: numberType().optional(),
|
|
3032
|
+
max_input_tokens: numberType().optional(),
|
|
3033
|
+
max_output_tokens: numberType().optional()
|
|
3031
3034
|
}), statuslineHookJsonSchema = objectType({
|
|
3032
3035
|
session_id: stringType(),
|
|
3033
3036
|
transcript_path: stringType(),
|
package/dist/calculate-cost.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./pricing-fetcher-
|
|
2
|
-
import { DailyUsage, MonthlyUsage, SessionUsage, WeeklyUsage } from "./data-loader-
|
|
1
|
+
import "./pricing-fetcher-BgDfBZ05.js";
|
|
2
|
+
import { DailyUsage, MonthlyUsage, SessionUsage, WeeklyUsage } from "./data-loader-BJnD_oR3.js";
|
|
3
3
|
|
|
4
4
|
//#region src/_token-utils.d.ts
|
|
5
5
|
|
package/dist/calculate-cost.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { getTotalTokens } from "./_token-utils-WjkbrjKv.js";
|
|
2
|
-
import "./_types-
|
|
2
|
+
import "./_types-BbEk8t2a.js";
|
|
3
3
|
import { calculateTotals, createTotalsObject } from "./calculate-cost-BDqO4yWA.js";
|
|
4
4
|
export { calculateTotals, createTotalsObject, getTotalTokens };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bucket, CostMode, PricingFetcher, SortOrder, TupleToUnion } from "./pricing-fetcher-
|
|
1
|
+
import { Bucket, CostMode, PricingFetcher, SortOrder, TupleToUnion } from "./pricing-fetcher-BgDfBZ05.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/_consts.d.ts
|
|
@@ -789,7 +789,7 @@ declare function loadBucketUsageData(groupingFn: (data: DailyUsage) => Bucket, o
|
|
|
789
789
|
* @param transcriptPath - Path to the transcript JSONL file
|
|
790
790
|
* @returns Object with context tokens info or null if unavailable
|
|
791
791
|
*/
|
|
792
|
-
declare function calculateContextTokens(transcriptPath: string): Promise<{
|
|
792
|
+
declare function calculateContextTokens(transcriptPath: string, modelId?: string, offline?: boolean): Promise<{
|
|
793
793
|
inputTokens: number;
|
|
794
794
|
percentage: number;
|
|
795
795
|
contextLimit: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CLAUDE_CONFIG_DIR_ENV, CLAUDE_PROJECTS_DIR_NAME,
|
|
1
|
+
import { CLAUDE_CONFIG_DIR_ENV, CLAUDE_PROJECTS_DIR_NAME, CONTEXT_LOW_THRESHOLD_ENV, CONTEXT_MEDIUM_THRESHOLD_ENV, DEFAULT_CLAUDE_CODE_PATH, DEFAULT_CLAUDE_CONFIG_PATH, DEFAULT_CONTEXT_USAGE_THRESHOLDS, DEFAULT_RECENT_DAYS, PricingFetcher, USAGE_DATA_GLOB_PATTERN, USER_HOME_DIR, __commonJSMin, __require, __toESM, isFailure, isPromise, isSuccess, require_usingCtx } from "./pricing-fetcher-s0HJ9Lpa.js";
|
|
2
2
|
import { getTotalTokens } from "./_token-utils-WjkbrjKv.js";
|
|
3
|
-
import { activityDateSchema, arrayType, booleanType, createBucket, createDailyDate, createMonthlyDate, createProjectPath, createSessionId, createWeeklyDate, dailyDateSchema, isoTimestampSchema, messageIdSchema, modelNameSchema, monthlyDateSchema, numberType, objectType, projectPathSchema, requestIdSchema, sessionIdSchema, stringType, unionType, versionSchema, weeklyDateSchema } from "./_types-
|
|
4
|
-
import { logger } from "./logger-
|
|
3
|
+
import { activityDateSchema, arrayType, booleanType, createBucket, createDailyDate, createMonthlyDate, createProjectPath, createSessionId, createWeeklyDate, dailyDateSchema, isoTimestampSchema, messageIdSchema, modelNameSchema, monthlyDateSchema, numberType, objectType, projectPathSchema, requestIdSchema, sessionIdSchema, stringType, unionType, versionSchema, weeklyDateSchema } from "./_types-BbEk8t2a.js";
|
|
4
|
+
import { logger } from "./logger-OEFb8rpr.js";
|
|
5
5
|
import a, { readFile } from "node:fs/promises";
|
|
6
6
|
import path, { posix } from "node:path";
|
|
7
7
|
import process$1 from "node:process";
|
|
@@ -462,19 +462,19 @@ var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
462
462
|
const { queue, options: { suppressErrors } } = state;
|
|
463
463
|
queue.enqueue(), fs_1$1.default.realpath(path$1, (error, resolvedPath) => {
|
|
464
464
|
if (error) return queue.dequeue(suppressErrors ? null : error, state);
|
|
465
|
-
fs_1$1.default.stat(resolvedPath, (error$1, stat) => {
|
|
465
|
+
fs_1$1.default.stat(resolvedPath, (error$1, stat$1) => {
|
|
466
466
|
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
467
|
-
if (stat.isDirectory() && isRecursive(path$1, resolvedPath, state)) return queue.dequeue(null, state);
|
|
468
|
-
callback$1(stat, resolvedPath), queue.dequeue(null, state);
|
|
467
|
+
if (stat$1.isDirectory() && isRecursive(path$1, resolvedPath, state)) return queue.dequeue(null, state);
|
|
468
|
+
callback$1(stat$1, resolvedPath), queue.dequeue(null, state);
|
|
469
469
|
});
|
|
470
470
|
});
|
|
471
471
|
}, resolveSymlinks = function(path$1, state, callback$1) {
|
|
472
472
|
const { queue, options: { suppressErrors } } = state;
|
|
473
473
|
queue.enqueue();
|
|
474
474
|
try {
|
|
475
|
-
const resolvedPath = fs_1$1.default.realpathSync(path$1), stat = fs_1$1.default.statSync(resolvedPath);
|
|
476
|
-
if (stat.isDirectory() && isRecursive(path$1, resolvedPath, state)) return;
|
|
477
|
-
callback$1(stat, resolvedPath);
|
|
475
|
+
const resolvedPath = fs_1$1.default.realpathSync(path$1), stat$1 = fs_1$1.default.statSync(resolvedPath);
|
|
476
|
+
if (stat$1.isDirectory() && isRecursive(path$1, resolvedPath, state)) return;
|
|
477
|
+
callback$1(stat$1, resolvedPath);
|
|
478
478
|
} catch (e) {
|
|
479
479
|
if (!suppressErrors) throw e;
|
|
480
480
|
}
|
|
@@ -664,8 +664,8 @@ var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
664
664
|
this.pushDirectory(path$1, paths, filters), this.walkDirectory(this.state, path$1, path$1, depth$1 - 1, this.walk);
|
|
665
665
|
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
666
666
|
let path$1 = joinPath.joinPathWithBasePath(entry.name, directoryPath);
|
|
667
|
-
this.resolveSymlink(path$1, this.state, (stat, resolvedPath) => {
|
|
668
|
-
if (stat.isDirectory()) {
|
|
667
|
+
this.resolveSymlink(path$1, this.state, (stat$1, resolvedPath) => {
|
|
668
|
+
if (stat$1.isDirectory()) {
|
|
669
669
|
if (resolvedPath = (0, utils_1.normalizePath)(resolvedPath, this.state.options), exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$1 + pathSeparator)) return;
|
|
670
670
|
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$1 + pathSeparator, depth$1 - 1, this.walk);
|
|
671
671
|
} else {
|
|
@@ -2669,7 +2669,7 @@ async function loadBucketUsageData(groupingFn, options) {
|
|
|
2669
2669
|
}
|
|
2670
2670
|
return sortByDate(buckets, (item) => item.bucket, options?.order);
|
|
2671
2671
|
}
|
|
2672
|
-
async function calculateContextTokens(transcriptPath) {
|
|
2672
|
+
async function calculateContextTokens(transcriptPath, modelId, offline = false) {
|
|
2673
2673
|
let content;
|
|
2674
2674
|
try {
|
|
2675
2675
|
content = await readFile(transcriptPath, "utf-8");
|
|
@@ -2685,11 +2685,24 @@ async function calculateContextTokens(transcriptPath) {
|
|
|
2685
2685
|
if (!result.success) continue;
|
|
2686
2686
|
const obj = result.data;
|
|
2687
2687
|
if (obj.type === "assistant" && obj.message != null && obj.message.usage != null && obj.message.usage.input_tokens != null) {
|
|
2688
|
-
const usage = obj.message.usage, inputTokens = usage.input_tokens + (usage.cache_creation_input_tokens ?? 0) + (usage.cache_read_input_tokens ?? 0)
|
|
2688
|
+
const usage = obj.message.usage, inputTokens = usage.input_tokens + (usage.cache_creation_input_tokens ?? 0) + (usage.cache_read_input_tokens ?? 0);
|
|
2689
|
+
let contextLimit = 2e5;
|
|
2690
|
+
if (modelId != null && modelId !== "") try {
|
|
2691
|
+
var _usingCtx5 = (0, import_usingCtx.default)();
|
|
2692
|
+
const fetcher = _usingCtx5.u(new PricingFetcher(offline)), contextLimitResult = await fetcher.getModelContextLimit(modelId);
|
|
2693
|
+
if (isSuccess(contextLimitResult) && contextLimitResult.value != null) contextLimit = contextLimitResult.value;
|
|
2694
|
+
else if (isSuccess(contextLimitResult)) logger.debug(`No context limit data available for model ${modelId} in LiteLLM`);
|
|
2695
|
+
else logger.debug(`Failed to get context limit for model ${modelId}: ${contextLimitResult.error.message}`);
|
|
2696
|
+
} catch (_) {
|
|
2697
|
+
_usingCtx5.e = _;
|
|
2698
|
+
} finally {
|
|
2699
|
+
_usingCtx5.d();
|
|
2700
|
+
}
|
|
2701
|
+
const percentage = Math.min(100, Math.max(0, Math.round(inputTokens / contextLimit * 100)));
|
|
2689
2702
|
return {
|
|
2690
2703
|
inputTokens,
|
|
2691
2704
|
percentage,
|
|
2692
|
-
contextLimit
|
|
2705
|
+
contextLimit
|
|
2693
2706
|
};
|
|
2694
2707
|
}
|
|
2695
2708
|
} catch {
|
|
@@ -2700,7 +2713,7 @@ async function calculateContextTokens(transcriptPath) {
|
|
|
2700
2713
|
}
|
|
2701
2714
|
async function loadSessionBlockData(options) {
|
|
2702
2715
|
try {
|
|
2703
|
-
var
|
|
2716
|
+
var _usingCtx6 = (0, import_usingCtx.default)();
|
|
2704
2717
|
const claudePaths = toArray(options?.claudePath ?? getClaudePaths()), allFiles = [];
|
|
2705
2718
|
for (const claudePath of claudePaths) {
|
|
2706
2719
|
const claudeDir = path.join(claudePath, CLAUDE_PROJECTS_DIR_NAME), files = await glob([USAGE_DATA_GLOB_PATTERN], {
|
|
@@ -2710,7 +2723,7 @@ async function loadSessionBlockData(options) {
|
|
|
2710
2723
|
allFiles.push(...files);
|
|
2711
2724
|
}
|
|
2712
2725
|
if (allFiles.length === 0) return [];
|
|
2713
|
-
const blocksFilteredFiles = filterByProject(allFiles, (filePath) => extractProjectFromPath(filePath), options?.project), sortedFiles = await sortFilesByTimestamp(blocksFilteredFiles), mode = options?.mode ?? "auto", fetcher =
|
|
2726
|
+
const blocksFilteredFiles = filterByProject(allFiles, (filePath) => extractProjectFromPath(filePath), options?.project), sortedFiles = await sortFilesByTimestamp(blocksFilteredFiles), mode = options?.mode ?? "auto", fetcher = _usingCtx6.u(mode === "display" ? null : new PricingFetcher(options?.offline)), processedHashes = /* @__PURE__ */ new Set(), allEntries = [];
|
|
2714
2727
|
for (const file of sortedFiles) {
|
|
2715
2728
|
const content = await readFile(file, "utf-8"), lines = content.trim().split("\n").filter((line) => line.length > 0);
|
|
2716
2729
|
for (const line of lines) try {
|
|
@@ -2743,9 +2756,9 @@ async function loadSessionBlockData(options) {
|
|
|
2743
2756
|
}) : blocks;
|
|
2744
2757
|
return sortByDate(dateFiltered, (block) => block.startTime, options?.order);
|
|
2745
2758
|
} catch (_) {
|
|
2746
|
-
|
|
2759
|
+
_usingCtx6.e = _;
|
|
2747
2760
|
} finally {
|
|
2748
|
-
|
|
2761
|
+
_usingCtx6.d();
|
|
2749
2762
|
}
|
|
2750
2763
|
}
|
|
2751
2764
|
export { DEFAULT_SESSION_DURATION_HOURS, bucketUsageSchema, calculateBurnRate, calculateContextTokens, calculateCostForEntry, createUniqueHash, dailyUsageSchema, extractProjectFromPath, filterRecentBlocks, formatDate, formatDateCompact, getClaudePaths, getContextUsageThresholds, getEarliestTimestamp, getUsageLimitResetTime, glob, globUsageFiles, identifySessionBlocks, loadBucketUsageData, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, loadSessionUsageById, loadWeeklyUsageData, modelBreakdownSchema, monthlyUsageSchema, projectBlockUsage, sessionUsageSchema, sortFilesByTimestamp, transcriptMessageSchema, transcriptUsageSchema, uniq, unwrap, usageDataSchema, weeklyUsageSchema };
|
package/dist/data-loader.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./pricing-fetcher-
|
|
2
|
-
import { BucketUsage, DailyUsage, DateFilter, GlobResult, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, WeeklyUsage, bucketUsageSchema, calculateContextTokens, calculateCostForEntry, createUniqueHash, dailyUsageSchema, extractProjectFromPath, formatDate, formatDateCompact, getClaudePaths, getContextUsageThresholds, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, loadBucketUsageData, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, loadSessionUsageById, loadWeeklyUsageData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, transcriptMessageSchema, transcriptUsageSchema, usageDataSchema, weeklyUsageSchema } from "./data-loader-
|
|
1
|
+
import "./pricing-fetcher-BgDfBZ05.js";
|
|
2
|
+
import { BucketUsage, DailyUsage, DateFilter, GlobResult, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, WeeklyUsage, bucketUsageSchema, calculateContextTokens, calculateCostForEntry, createUniqueHash, dailyUsageSchema, extractProjectFromPath, formatDate, formatDateCompact, getClaudePaths, getContextUsageThresholds, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, loadBucketUsageData, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, loadSessionUsageById, loadWeeklyUsageData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, transcriptMessageSchema, transcriptUsageSchema, usageDataSchema, weeklyUsageSchema } from "./data-loader-BJnD_oR3.js";
|
|
3
3
|
export { BucketUsage, DailyUsage, DateFilter, GlobResult, LoadOptions, ModelBreakdown, MonthlyUsage, SessionUsage, UsageData, WeeklyUsage, bucketUsageSchema, calculateContextTokens, calculateCostForEntry, createUniqueHash, dailyUsageSchema, extractProjectFromPath, formatDate, formatDateCompact, getClaudePaths, getContextUsageThresholds, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, loadBucketUsageData, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, loadSessionUsageById, loadWeeklyUsageData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, transcriptMessageSchema, transcriptUsageSchema, usageDataSchema, weeklyUsageSchema };
|
package/dist/data-loader.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./pricing-fetcher-
|
|
1
|
+
import "./pricing-fetcher-s0HJ9Lpa.js";
|
|
2
2
|
import "./_token-utils-WjkbrjKv.js";
|
|
3
|
-
import "./_types-
|
|
4
|
-
import { bucketUsageSchema, calculateContextTokens, calculateCostForEntry, createUniqueHash, dailyUsageSchema, extractProjectFromPath, formatDate, formatDateCompact, getClaudePaths, getContextUsageThresholds, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, loadBucketUsageData, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, loadSessionUsageById, loadWeeklyUsageData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, transcriptMessageSchema, transcriptUsageSchema, usageDataSchema, weeklyUsageSchema } from "./data-loader-
|
|
5
|
-
import "./logger-
|
|
3
|
+
import "./_types-BbEk8t2a.js";
|
|
4
|
+
import { bucketUsageSchema, calculateContextTokens, calculateCostForEntry, createUniqueHash, dailyUsageSchema, extractProjectFromPath, formatDate, formatDateCompact, getClaudePaths, getContextUsageThresholds, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, loadBucketUsageData, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, loadSessionUsageById, loadWeeklyUsageData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, transcriptMessageSchema, transcriptUsageSchema, usageDataSchema, weeklyUsageSchema } from "./data-loader-DGO3W7OE.js";
|
|
5
|
+
import "./logger-OEFb8rpr.js";
|
|
6
6
|
export { bucketUsageSchema, calculateContextTokens, calculateCostForEntry, createUniqueHash, dailyUsageSchema, extractProjectFromPath, formatDate, formatDateCompact, getClaudePaths, getContextUsageThresholds, getEarliestTimestamp, getUsageLimitResetTime, globUsageFiles, loadBucketUsageData, loadDailyUsageData, loadMonthlyUsageData, loadSessionBlockData, loadSessionData, loadSessionUsageById, loadWeeklyUsageData, modelBreakdownSchema, monthlyUsageSchema, sessionUsageSchema, sortFilesByTimestamp, transcriptMessageSchema, transcriptUsageSchema, usageDataSchema, weeklyUsageSchema };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CLAUDE_PROJECTS_DIR_NAME, DEBUG_MATCH_THRESHOLD_PERCENT, PricingFetcher, USAGE_DATA_GLOB_PATTERN, __toESM, isFailure, require_usingCtx, try_ } from "./pricing-fetcher-
|
|
2
|
-
import { getClaudePaths, glob, unwrap, usageDataSchema } from "./data-loader-
|
|
3
|
-
import { logger } from "./logger-
|
|
1
|
+
import { CLAUDE_PROJECTS_DIR_NAME, DEBUG_MATCH_THRESHOLD_PERCENT, PricingFetcher, USAGE_DATA_GLOB_PATTERN, __toESM, isFailure, require_usingCtx, try_ } from "./pricing-fetcher-s0HJ9Lpa.js";
|
|
2
|
+
import { getClaudePaths, glob, unwrap, usageDataSchema } from "./data-loader-DGO3W7OE.js";
|
|
3
|
+
import { logger } from "./logger-OEFb8rpr.js";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
var import_usingCtx = /* @__PURE__ */ __toESM(require_usingCtx(), 1);
|
package/dist/debug.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "./pricing-fetcher-
|
|
1
|
+
import "./pricing-fetcher-s0HJ9Lpa.js";
|
|
2
2
|
import "./_token-utils-WjkbrjKv.js";
|
|
3
|
-
import "./_types-
|
|
4
|
-
import "./data-loader-
|
|
5
|
-
import "./logger-
|
|
6
|
-
import { detectMismatches, printMismatchReport } from "./debug-
|
|
3
|
+
import "./_types-BbEk8t2a.js";
|
|
4
|
+
import "./data-loader-DGO3W7OE.js";
|
|
5
|
+
import "./logger-OEFb8rpr.js";
|
|
6
|
+
import { detectMismatches, printMismatchReport } from "./debug-DobNnsGn.js";
|
|
7
7
|
export { detectMismatches, printMismatchReport };
|