getaimeter 0.11.3 → 0.11.4
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/watcher.js +9 -31
package/package.json
CHANGED
package/watcher.js
CHANGED
|
@@ -348,30 +348,6 @@ function extractNewUsage(filePath) {
|
|
|
348
348
|
continue;
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
-
// ── Copilot VS Code agent: real-time per-turn output tracking ──
|
|
352
|
-
// assistant.message fires after every AI response with data.outputTokens.
|
|
353
|
-
// Input tokens are not available per-turn — they come from session.shutdown.
|
|
354
|
-
if (obj.type === 'assistant.message' && obj.data?.outputTokens > 0) {
|
|
355
|
-
const msgId = obj.data.messageId;
|
|
356
|
-
const hashKey = `${filePath}:copilot-msg:${msgId}`;
|
|
357
|
-
const hash = crypto.createHash('md5').update(hashKey).digest('hex');
|
|
358
|
-
if (isDuplicate(hash)) continue;
|
|
359
|
-
|
|
360
|
-
usageEvents.push({
|
|
361
|
-
provider: 'github',
|
|
362
|
-
model: 'copilot',
|
|
363
|
-
source: detectSource(filePath),
|
|
364
|
-
inputTokens: 0,
|
|
365
|
-
outputTokens: obj.data.outputTokens,
|
|
366
|
-
thinkingTokens: 0,
|
|
367
|
-
cacheReadTokens: 0,
|
|
368
|
-
cacheWriteTokens: 0,
|
|
369
|
-
conversationId: convMeta.conversationId,
|
|
370
|
-
projectPath: convMeta.projectPath,
|
|
371
|
-
});
|
|
372
|
-
continue;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
351
|
// ── Copilot format (old: token_usage, new: session.shutdown with modelMetrics) ──
|
|
376
352
|
if (obj.type === 'token_usage' && (obj.input_tokens !== undefined || obj.output_tokens !== undefined)) {
|
|
377
353
|
const copilotModel = obj.model || 'copilot';
|
|
@@ -395,18 +371,20 @@ function extractNewUsage(filePath) {
|
|
|
395
371
|
}
|
|
396
372
|
|
|
397
373
|
// GitHub Copilot agent: session.shutdown reports the per-model session totals.
|
|
398
|
-
//
|
|
399
|
-
//
|
|
374
|
+
// We report full tokens (input + output) here with real model names.
|
|
375
|
+
// assistant.message per-turn events are intentionally skipped — they don't
|
|
376
|
+
// include a model field, which would cause all output to be misattributed
|
|
377
|
+
// to a generic "copilot" entry instead of the actual model used.
|
|
400
378
|
if (obj.type === 'session.shutdown' && obj.data?.modelMetrics) {
|
|
401
379
|
for (const [model, metrics] of Object.entries(obj.data.modelMetrics)) {
|
|
402
380
|
const u = metrics.usage || {};
|
|
403
|
-
const inputTokens
|
|
381
|
+
const inputTokens = u.inputTokens || 0;
|
|
382
|
+
const outputTokens = u.outputTokens || 0;
|
|
404
383
|
const cacheReadTokens = u.cacheReadTokens || 0;
|
|
405
384
|
const cacheWriteTokens = u.cacheWriteTokens || 0;
|
|
406
|
-
|
|
407
|
-
if (inputTokens === 0 && cacheReadTokens === 0) continue;
|
|
385
|
+
if (inputTokens === 0 && outputTokens === 0 && cacheReadTokens === 0) continue;
|
|
408
386
|
|
|
409
|
-
const hashKey = `${filePath}:copilot-shutdown
|
|
387
|
+
const hashKey = `${filePath}:copilot-shutdown:${model}:${inputTokens}:${outputTokens}`;
|
|
410
388
|
const hash = crypto.createHash('md5').update(hashKey).digest('hex');
|
|
411
389
|
if (isDuplicate(hash)) continue;
|
|
412
390
|
|
|
@@ -421,7 +399,7 @@ function extractNewUsage(filePath) {
|
|
|
421
399
|
model,
|
|
422
400
|
source: detectSource(filePath),
|
|
423
401
|
inputTokens,
|
|
424
|
-
outputTokens
|
|
402
|
+
outputTokens,
|
|
425
403
|
thinkingTokens: 0,
|
|
426
404
|
cacheReadTokens,
|
|
427
405
|
cacheWriteTokens,
|