@yhong91/vibetime 0.1.4 → 0.1.5
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 +84 -2
- package/package.json +1 -1
package/bin/vibetime.mjs
CHANGED
|
@@ -1195,7 +1195,7 @@ function countTextLines(text) {
|
|
|
1195
1195
|
}
|
|
1196
1196
|
|
|
1197
1197
|
// src/lib/constants.ts
|
|
1198
|
-
var PACKAGE_VERSION = true ? "0.1.
|
|
1198
|
+
var PACKAGE_VERSION = true ? "0.1.5" : "0.1.1";
|
|
1199
1199
|
var DEFAULT_API_URL = "http://121.196.224.82:3001";
|
|
1200
1200
|
var DEFAULT_BACKFILL_BATCH_SIZE = 50;
|
|
1201
1201
|
var DEFAULT_BACKFILL_BATCH_BYTES = 800 * 1024;
|
|
@@ -3024,6 +3024,7 @@ function createClaudeCoworkAdapter() {
|
|
|
3024
3024
|
// src/adapters/codebuddy.ts
|
|
3025
3025
|
import { readFile as readFile5, readdir as readdir4 } from "node:fs/promises";
|
|
3026
3026
|
import path8 from "node:path";
|
|
3027
|
+
var ENDPOINT_MODEL_ID_RE = /^(?:ep|endpoint)-/i;
|
|
3027
3028
|
async function parseCodebuddyTraceFile(filePath, options) {
|
|
3028
3029
|
const text = await readFile5(filePath, "utf8");
|
|
3029
3030
|
const sourcePathHash = `sha256:${createStableHash(filePath)}`;
|
|
@@ -3051,7 +3052,7 @@ async function parseCodebuddyTraceFile(filePath, options) {
|
|
|
3051
3052
|
}
|
|
3052
3053
|
const project = cwd ? path8.basename(cwd) : void 0;
|
|
3053
3054
|
const workspaceId = createWorkspaceId({ projectName: project, repoRoot: cwd });
|
|
3054
|
-
const model = trace
|
|
3055
|
+
const model = resolveCodebuddyModel(trace, spans);
|
|
3055
3056
|
const baseEvent = (event) => ({
|
|
3056
3057
|
schemaVersion: AGENT_TIME_SCHEMA_VERSION,
|
|
3057
3058
|
source: "codebuddy",
|
|
@@ -3314,6 +3315,87 @@ async function parseCodebuddyTraceFile(filePath, options) {
|
|
|
3314
3315
|
}
|
|
3315
3316
|
return events.filter((event) => validateCanonicalEvent(event).valid);
|
|
3316
3317
|
}
|
|
3318
|
+
function resolveCodebuddyModel(trace, spans) {
|
|
3319
|
+
const spanModel = modelFromSpans(spans);
|
|
3320
|
+
if (spanModel) {
|
|
3321
|
+
return spanModel;
|
|
3322
|
+
}
|
|
3323
|
+
const metadataModel = findHumanModelName(trace.metadata);
|
|
3324
|
+
if (metadataModel) {
|
|
3325
|
+
return metadataModel;
|
|
3326
|
+
}
|
|
3327
|
+
for (const candidate of trace.modelInfo?.models || []) {
|
|
3328
|
+
const normalized = normalizeModelCandidate(candidate);
|
|
3329
|
+
if (normalized) {
|
|
3330
|
+
return normalized;
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3333
|
+
return void 0;
|
|
3334
|
+
}
|
|
3335
|
+
function modelFromSpans(spans) {
|
|
3336
|
+
for (const span of spans) {
|
|
3337
|
+
const parsedOutput = parseEmbeddedJson(span.toolOutput);
|
|
3338
|
+
const outputModel = findHumanModelName(parsedOutput);
|
|
3339
|
+
if (outputModel) {
|
|
3340
|
+
return outputModel;
|
|
3341
|
+
}
|
|
3342
|
+
const parsedInput = parseEmbeddedJson(span.toolInput);
|
|
3343
|
+
const inputModel = findHumanModelName(parsedInput);
|
|
3344
|
+
if (inputModel) {
|
|
3345
|
+
return inputModel;
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3348
|
+
return void 0;
|
|
3349
|
+
}
|
|
3350
|
+
function parseEmbeddedJson(value) {
|
|
3351
|
+
if (!value?.trim()) {
|
|
3352
|
+
return void 0;
|
|
3353
|
+
}
|
|
3354
|
+
try {
|
|
3355
|
+
return JSON.parse(value);
|
|
3356
|
+
} catch {
|
|
3357
|
+
return void 0;
|
|
3358
|
+
}
|
|
3359
|
+
}
|
|
3360
|
+
function findHumanModelName(value) {
|
|
3361
|
+
const queue = [value];
|
|
3362
|
+
while (queue.length > 0) {
|
|
3363
|
+
const current = queue.shift();
|
|
3364
|
+
if (Array.isArray(current)) {
|
|
3365
|
+
queue.push(...current);
|
|
3366
|
+
continue;
|
|
3367
|
+
}
|
|
3368
|
+
if (!isPlainObject(current)) {
|
|
3369
|
+
continue;
|
|
3370
|
+
}
|
|
3371
|
+
const preferred = [
|
|
3372
|
+
stringField(current, "requestModelName"),
|
|
3373
|
+
stringField(current, "modelName"),
|
|
3374
|
+
stringField(current, "model_name"),
|
|
3375
|
+
stringField(current, "model"),
|
|
3376
|
+
stringField(current, "requestModelId"),
|
|
3377
|
+
stringField(current, "modelId")
|
|
3378
|
+
];
|
|
3379
|
+
for (const candidate of preferred) {
|
|
3380
|
+
const normalized = normalizeModelCandidate(candidate);
|
|
3381
|
+
if (normalized) {
|
|
3382
|
+
return normalized;
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
queue.push(...Object.values(current));
|
|
3386
|
+
}
|
|
3387
|
+
return void 0;
|
|
3388
|
+
}
|
|
3389
|
+
function normalizeModelCandidate(value) {
|
|
3390
|
+
if (!value) {
|
|
3391
|
+
return void 0;
|
|
3392
|
+
}
|
|
3393
|
+
const trimmed = value.trim();
|
|
3394
|
+
if (!trimmed || ENDPOINT_MODEL_ID_RE.test(trimmed)) {
|
|
3395
|
+
return void 0;
|
|
3396
|
+
}
|
|
3397
|
+
return trimmed;
|
|
3398
|
+
}
|
|
3317
3399
|
function modelUsageFromTrace(trace, generationIndex, totalGenerations) {
|
|
3318
3400
|
const info = trace.modelInfo;
|
|
3319
3401
|
if (!info || !info.totalInputTokens && !info.totalOutputTokens && !trace.totalTokens) {
|
package/package.json
CHANGED