burnoff 1.3.0 → 1.4.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.
@@ -217,11 +217,15 @@ export function stitchClaudeCodeDag(jsonlLinesOrContent = []) {
217
217
  prevMsg.content ?? prev.content,
218
218
  nextMsg.content ?? node.content
219
219
  );
220
+ const prevTs = prev.firstChunkAt || prev.timestamp || prev.created_at || prev.createdAt || null;
221
+ const nextTs = node.timestamp || node.created_at || node.createdAt || prev.lastChunkAt || prevTs;
220
222
  consolidatedActiveChain[idx] = {
221
223
  ...prev,
222
224
  ...node,
223
225
  uuid: node.uuid || prev.uuid,
224
226
  parentUuid: prev.parentUuid,
227
+ firstChunkAt: prevTs,
228
+ lastChunkAt: nextTs,
225
229
  content: msg ? prev.content : mergedContent,
226
230
  tool_calls: [
227
231
  ...(Array.isArray(prev.tool_calls) ? prev.tool_calls : []),
@@ -500,7 +504,27 @@ export function parseClaudeCodeJsonl(rawContent = '') {
500
504
  ) || 0);
501
505
  const model = msg?.model || node.model || null;
502
506
  if (model) latestModel = model;
503
- const createdAt = node.timestamp || node.created_at || node.createdAt || null;
507
+ const createdAt = node.firstChunkAt || node.timestamp || node.created_at || node.createdAt || null;
508
+ const finishedAt = node.finished_at || node.finishedAt || node.completedAt || node.lastChunkAt || null;
509
+ const firstTokenAt = node.first_token_at || node.firstTokenAt || null;
510
+ const rawDur = Number(node.durationMs ?? node.duration_ms ?? node.latencyMs);
511
+ let durationMs = Number.isFinite(rawDur) && rawDur > 0 ? Number(rawDur.toFixed(2)) : null;
512
+ if (durationMs === null && createdAt && finishedAt) {
513
+ const startMs = Date.parse(createdAt);
514
+ const endMs = Date.parse(finishedAt);
515
+ if (Number.isFinite(startMs) && Number.isFinite(endMs) && endMs > startMs) {
516
+ durationMs = Number((endMs - startMs).toFixed(2));
517
+ }
518
+ }
519
+ const rawTtft = Number(node.ttftMs ?? node.ttft_ms ?? node.firstTokenLatencyMs);
520
+ let ttftMs = Number.isFinite(rawTtft) && rawTtft > 0 ? Number(rawTtft.toFixed(2)) : null;
521
+ if (ttftMs === null && createdAt && firstTokenAt) {
522
+ const startMs = Date.parse(createdAt);
523
+ const firstMs = Date.parse(firstTokenAt);
524
+ if (Number.isFinite(startMs) && Number.isFinite(firstMs) && firstMs >= startMs) {
525
+ ttftMs = Number((firstMs - startMs).toFixed(2));
526
+ }
527
+ }
504
528
  const hasUsage = inputTokens > 0 || cacheReadTokens > 0 || cacheCreationTokens > 0 || outputTokens > 0;
505
529
  const hadCompactionBefore = hasUsage ? pendingCompaction : false;
506
530
  if (hasUsage) {
@@ -544,6 +568,10 @@ export function parseClaudeCodeJsonl(rawContent = '') {
544
568
  systemSubtype,
545
569
  status: 'DONE',
546
570
  createdAt,
571
+ finishedAt,
572
+ firstTokenAt,
573
+ durationMs,
574
+ ttftMs,
547
575
  model: model || latestModel || null,
548
576
  toolCalls,
549
577
  content,