@vibe-cafe/vibe-usage 0.2.5 → 0.2.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-cafe/vibe-usage",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Track your AI coding tool token usage and sync to vibecafe.ai",
5
5
  "type": "module",
6
6
  "bin": {
@@ -81,18 +81,17 @@ export async function parse(lastSync) {
81
81
  try {
82
82
  const obj = JSON.parse(line);
83
83
 
84
+ // Capture model from top-level turn_context entries
85
+ if (obj.type === 'turn_context' && obj.payload?.model) {
86
+ turnContextModel = obj.payload.model;
87
+ continue;
88
+ }
84
89
 
85
90
  if (obj.type !== 'event_msg') continue;
86
91
 
87
92
  const payload = obj.payload;
88
93
  if (!payload) continue;
89
94
 
90
- // Capture model from turn_context events
91
- if (payload.type === 'turn_context' && payload.model) {
92
- turnContextModel = payload.model;
93
- continue;
94
- }
95
-
96
95
  if (payload.type !== 'token_count') continue;
97
96
 
98
97
  const info = payload.info;
@@ -105,7 +104,7 @@ export async function parse(lastSync) {
105
104
  // Prefer incremental per-request usage; compute delta from cumulative total as fallback
106
105
  let usage = info.last_token_usage;
107
106
  if (!usage && info.total_token_usage) {
108
- const totalKey = `${info.model || payload.model || ''}`;
107
+ const totalKey = `${info.model || payload.model || turnContextModel || ''}`;
109
108
  const prev = prevTotal.get(totalKey);
110
109
  const curr = info.total_token_usage;
111
110
  if (prev) {