@yhong91/vibetime 0.1.18 → 0.1.20
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/bin/vibetime.mjs +33 -3
- package/package.json +1 -1
package/bin/vibetime.mjs
CHANGED
|
@@ -1202,7 +1202,7 @@ function countTextLines(text) {
|
|
|
1202
1202
|
}
|
|
1203
1203
|
|
|
1204
1204
|
// src/lib/constants.ts
|
|
1205
|
-
var PACKAGE_VERSION = true ? "0.1.
|
|
1205
|
+
var PACKAGE_VERSION = true ? "0.1.20" : "0.1.1";
|
|
1206
1206
|
var DEFAULT_API_URL = "http://121.196.224.82:3001";
|
|
1207
1207
|
var DEFAULT_BACKFILL_BATCH_SIZE = 50;
|
|
1208
1208
|
var DEFAULT_BACKFILL_BATCH_BYTES = 800 * 1024;
|
|
@@ -3431,8 +3431,9 @@ async function parseCodebuddyTraceFile(filePath, options) {
|
|
|
3431
3431
|
}
|
|
3432
3432
|
const trace = traceFile.trace;
|
|
3433
3433
|
const spans = Array.isArray(traceFile.spans) ? traceFile.spans : [];
|
|
3434
|
+
const hasGenerationSpans = spans.some((s) => s.type === "generation");
|
|
3434
3435
|
const hasFunctionSpans = spans.some((s) => s.type === "function");
|
|
3435
|
-
const isTrivial = !
|
|
3436
|
+
const isTrivial = !hasGenerationSpans && !hasFunctionSpans;
|
|
3436
3437
|
if (isTrivial) {
|
|
3437
3438
|
return [];
|
|
3438
3439
|
}
|
|
@@ -3608,7 +3609,10 @@ async function parseCodebuddyTraceFile(filePath, options) {
|
|
|
3608
3609
|
}
|
|
3609
3610
|
if (span.type === "generation") {
|
|
3610
3611
|
generationCount++;
|
|
3611
|
-
const usage = modelUsageFromTrace(trace, generationCount, totalGenerations);
|
|
3612
|
+
const usage = extractUsageFromGenerationSpan(span) ?? modelUsageFromTrace(trace, generationCount, totalGenerations);
|
|
3613
|
+
if (!usage && !model) {
|
|
3614
|
+
continue;
|
|
3615
|
+
}
|
|
3612
3616
|
push(baseEvent({
|
|
3613
3617
|
ts,
|
|
3614
3618
|
type: "model.usage",
|
|
@@ -3787,6 +3791,32 @@ function normalizeModelCandidate(value) {
|
|
|
3787
3791
|
}
|
|
3788
3792
|
return trimmed;
|
|
3789
3793
|
}
|
|
3794
|
+
function extractUsageFromGenerationSpan(span) {
|
|
3795
|
+
const parsed = parseEmbeddedJson(span.toolOutput);
|
|
3796
|
+
if (!Array.isArray(parsed) || parsed.length === 0) {
|
|
3797
|
+
return void 0;
|
|
3798
|
+
}
|
|
3799
|
+
const first = parsed[0];
|
|
3800
|
+
if (!isPlainObject(first)) {
|
|
3801
|
+
return void 0;
|
|
3802
|
+
}
|
|
3803
|
+
const usage = objectField(first, "usage");
|
|
3804
|
+
if (!isPlainObject(usage)) {
|
|
3805
|
+
return void 0;
|
|
3806
|
+
}
|
|
3807
|
+
const inputTokens = numberField(usage, "prompt_tokens");
|
|
3808
|
+
const outputTokens = numberField(usage, "completion_tokens");
|
|
3809
|
+
const totalTokens = numberField(usage, "total_tokens");
|
|
3810
|
+
const details = objectField(usage, "prompt_tokens_details");
|
|
3811
|
+
const cachedTokens = isPlainObject(details) ? numberField(details, "cached_tokens") : void 0;
|
|
3812
|
+
return {
|
|
3813
|
+
tokensInput: inputTokens || void 0,
|
|
3814
|
+
tokensCachedInput: cachedTokens || void 0,
|
|
3815
|
+
tokensOutput: outputTokens || void 0,
|
|
3816
|
+
tokensTotal: totalTokens || void 0,
|
|
3817
|
+
modelCalls: 1
|
|
3818
|
+
};
|
|
3819
|
+
}
|
|
3790
3820
|
function modelUsageFromTrace(trace, generationIndex, totalGenerations) {
|
|
3791
3821
|
const info = trace.modelInfo;
|
|
3792
3822
|
if (!info || !info.totalInputTokens && !info.totalOutputTokens && !trace.totalTokens) {
|
package/package.json
CHANGED