@vibe-cafe/vibe-usage 0.5.0 → 0.5.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/package.json +1 -1
- package/src/parsers/codex.js +8 -4
- package/src/parsers/gemini-cli.js +14 -10
- package/src/parsers/index.js +1 -1
package/package.json
CHANGED
package/src/parsers/codex.js
CHANGED
|
@@ -115,15 +115,19 @@ export async function parse() {
|
|
|
115
115
|
|
|
116
116
|
const model = info.model || payload.model || turnContextModel || sessionModel;
|
|
117
117
|
|
|
118
|
+
// OpenAI API: input_tokens INCLUDES cached, output_tokens INCLUDES reasoning.
|
|
119
|
+
// Normalize to Anthropic-style semantics where each field is non-overlapping.
|
|
120
|
+
const cachedInput = usage.cached_input_tokens || usage.cache_read_input_tokens || 0;
|
|
121
|
+
const reasoningOutput = usage.reasoning_output_tokens || 0;
|
|
118
122
|
entries.push({
|
|
119
123
|
source: 'codex',
|
|
120
124
|
model,
|
|
121
125
|
project: sessionProject,
|
|
122
126
|
timestamp,
|
|
123
|
-
inputTokens: usage.input_tokens || 0,
|
|
124
|
-
outputTokens: usage.output_tokens || 0,
|
|
125
|
-
cachedInputTokens:
|
|
126
|
-
reasoningOutputTokens:
|
|
127
|
+
inputTokens: (usage.input_tokens || 0) - cachedInput,
|
|
128
|
+
outputTokens: (usage.output_tokens || 0) - reasoningOutput,
|
|
129
|
+
cachedInputTokens: cachedInput,
|
|
130
|
+
reasoningOutputTokens: reasoningOutput,
|
|
127
131
|
});
|
|
128
132
|
} catch {
|
|
129
133
|
continue;
|
|
@@ -59,28 +59,32 @@ export async function parse() {
|
|
|
59
59
|
if (isNaN(ts.getTime())) continue;
|
|
60
60
|
|
|
61
61
|
if (tokens) {
|
|
62
|
-
//
|
|
62
|
+
// Gemini API: input INCLUDES cached, output INCLUDES thoughts. Normalize to non-overlapping.
|
|
63
|
+
const cached = tokens.cached || 0;
|
|
64
|
+
const thoughts = tokens.thoughts || 0;
|
|
63
65
|
entries.push({
|
|
64
66
|
source: 'gemini-cli',
|
|
65
67
|
model: msg.model || data.model || 'unknown',
|
|
66
68
|
project: 'unknown',
|
|
67
69
|
timestamp: ts,
|
|
68
|
-
inputTokens: tokens.input || 0,
|
|
69
|
-
outputTokens: tokens.output || 0,
|
|
70
|
-
cachedInputTokens:
|
|
71
|
-
reasoningOutputTokens:
|
|
70
|
+
inputTokens: (tokens.input || 0) - cached,
|
|
71
|
+
outputTokens: (tokens.output || 0) - thoughts,
|
|
72
|
+
cachedInputTokens: cached,
|
|
73
|
+
reasoningOutputTokens: thoughts,
|
|
72
74
|
});
|
|
73
75
|
} else {
|
|
74
|
-
//
|
|
76
|
+
// Gemini API: promptTokenCount INCLUDES cachedContentTokenCount. Normalize to non-overlapping.
|
|
77
|
+
const cached = usage.cachedContentTokenCount || 0;
|
|
78
|
+
const thoughts = usage.thoughtsTokenCount || 0;
|
|
75
79
|
entries.push({
|
|
76
80
|
source: 'gemini-cli',
|
|
77
81
|
model: msg.model || data.model || 'unknown',
|
|
78
82
|
project: 'unknown',
|
|
79
83
|
timestamp: ts,
|
|
80
|
-
inputTokens: usage.promptTokenCount || usage.input_tokens || 0,
|
|
81
|
-
outputTokens: usage.candidatesTokenCount || usage.output_tokens || 0,
|
|
82
|
-
cachedInputTokens:
|
|
83
|
-
reasoningOutputTokens:
|
|
84
|
+
inputTokens: (usage.promptTokenCount || usage.input_tokens || 0) - cached,
|
|
85
|
+
outputTokens: (usage.candidatesTokenCount || usage.output_tokens || 0) - thoughts,
|
|
86
|
+
cachedInputTokens: cached,
|
|
87
|
+
reasoningOutputTokens: thoughts,
|
|
84
88
|
});
|
|
85
89
|
}
|
|
86
90
|
}
|
package/src/parsers/index.js
CHANGED
|
@@ -45,7 +45,7 @@ export function aggregateToBuckets(entries) {
|
|
|
45
45
|
b.outputTokens += e.outputTokens || 0;
|
|
46
46
|
b.cachedInputTokens += e.cachedInputTokens || 0;
|
|
47
47
|
b.reasoningOutputTokens += e.reasoningOutputTokens || 0;
|
|
48
|
-
b.totalTokens += (e.inputTokens || 0) + (e.outputTokens || 0);
|
|
48
|
+
b.totalTokens += (e.inputTokens || 0) + (e.outputTokens || 0) + (e.reasoningOutputTokens || 0);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
return Array.from(map.values());
|