@kodaris/krubble-app-components 1.0.167 → 1.0.169

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.
@@ -6395,6 +6395,12 @@
6395
6395
  }
6396
6396
  return '$' + n.toFixed(2);
6397
6397
  }
6398
+ _fmtPriceDetail(n) {
6399
+ if (n == null || isNaN(n)) {
6400
+ return '—';
6401
+ }
6402
+ return '$' + n.toFixed(4);
6403
+ }
6398
6404
  _getCustomerPriceLabel() {
6399
6405
  const rate = this._telemetry?.customerPricePerThousandTokens;
6400
6406
  if (rate == null || isNaN(rate)) {
@@ -6402,6 +6408,28 @@
6402
6408
  }
6403
6409
  return `Customer price ($${rate}/1K)`;
6404
6410
  }
6411
+ _getMarkupPriceLabel() {
6412
+ const pct = this._telemetry?.customerMarkupPercent;
6413
+ if (pct == null || isNaN(pct)) {
6414
+ return 'Customer price (markup)';
6415
+ }
6416
+ return `Customer price (${pct}% markup)`;
6417
+ }
6418
+ _getTurnCacheWriteTokens() {
6419
+ return this._iterationLog.reduce((sum, it) => sum + (it.iterationCacheWrite || 0), 0);
6420
+ }
6421
+ _renderMarkupBreakdown(input, output, cacheRead, cacheWrite) {
6422
+ return b `
6423
+ <span class="debug-metrics__key debug-metrics__key--sub">Input</span>
6424
+ <span class="debug-metrics__val debug-metrics__val--sub">${this._fmtPriceDetail(input)}</span>
6425
+ <span class="debug-metrics__key debug-metrics__key--sub">Output</span>
6426
+ <span class="debug-metrics__val debug-metrics__val--sub">${this._fmtPriceDetail(output)}</span>
6427
+ <span class="debug-metrics__key debug-metrics__key--sub">Cache read</span>
6428
+ <span class="debug-metrics__val debug-metrics__val--sub">${this._fmtPriceDetail(cacheRead)}</span>
6429
+ <span class="debug-metrics__key debug-metrics__key--sub">Cache write</span>
6430
+ <span class="debug-metrics__val debug-metrics__val--sub">${this._fmtPriceDetail(cacheWrite)}</span>
6431
+ `;
6432
+ }
6405
6433
  /**
6406
6434
  * INTERNAL-ONLY debug telemetry panel. Rendered only in the inline variant
6407
6435
  * (guarded by the caller) and only when the user has toggled it open. Shows
@@ -6775,11 +6803,13 @@
6775
6803
  <div class="debug-section__label">This turn</div>
6776
6804
  <div class="debug-metrics">
6777
6805
  <span class="debug-metrics__key">Input</span>
6778
- <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.turnInputTokens)}</span>
6806
+ <span class="debug-metrics__val">${this._fmtTokens(Math.max(0, (this._telemetry.turnInputTokens || 0) - this._getTurnCacheWriteTokens()))}</span>
6779
6807
  <span class="debug-metrics__key">Output</span>
6780
6808
  <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.turnOutputTokens)}</span>
6781
6809
  <span class="debug-metrics__key">Cache read</span>
6782
6810
  <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.turnCacheReadTokens)}</span>
6811
+ <span class="debug-metrics__key">Cache write</span>
6812
+ <span class="debug-metrics__val">${this._fmtTokens(this._getTurnCacheWriteTokens())}</span>
6783
6813
  <span class="debug-metrics__key">Hit rate</span>
6784
6814
  <span class="debug-metrics__val">${this._telemetry.turnHitRate ?? '—'}%</span>
6785
6815
  <span class="debug-metrics__key">Total tokens</span>
@@ -6790,6 +6820,9 @@
6790
6820
  <span class="debug-metrics__val debug-cost">${this._fmtCost(this._telemetry.turnCostUsd)}</span>
6791
6821
  <span class="debug-metrics__key">${this._getCustomerPriceLabel()}</span>
6792
6822
  <span class="debug-metrics__val debug-cost">${this._fmtPrice(this._telemetry.turnCustomerUsd)}</span>
6823
+ <span class="debug-metrics__key">${this._getMarkupPriceLabel()}</span>
6824
+ <span class="debug-metrics__val debug-cost">${this._fmtPrice(this._telemetry.turnMarkupCustomerUsd)}</span>
6825
+ ${this._renderMarkupBreakdown(this._telemetry.turnMarkupInputUsd, this._telemetry.turnMarkupOutputUsd, this._telemetry.turnMarkupCacheReadUsd, this._telemetry.turnMarkupCacheWriteUsd)}
6793
6826
  </div>
6794
6827
  </div>
6795
6828
 
@@ -6810,6 +6843,9 @@
6810
6843
  <span class="debug-metrics__val debug-cost">${this._fmtCost(this._telemetry.conversationCostUsd)}</span>
6811
6844
  <span class="debug-metrics__key">${this._getCustomerPriceLabel()} so far</span>
6812
6845
  <span class="debug-metrics__val debug-cost">${this._fmtPrice(this._telemetry.conversationCustomerUsd)}</span>
6846
+ <span class="debug-metrics__key">${this._getMarkupPriceLabel()} so far</span>
6847
+ <span class="debug-metrics__val debug-cost">${this._fmtPrice(this._telemetry.conversationMarkupCustomerUsd)}</span>
6848
+ ${this._renderMarkupBreakdown(this._telemetry.conversationMarkupInputUsd, this._telemetry.conversationMarkupOutputUsd, this._telemetry.conversationMarkupCacheReadUsd, this._telemetry.conversationMarkupCacheWriteUsd)}
6813
6849
  </div>
6814
6850
  </div>
6815
6851
  ` : b `
@@ -6833,6 +6869,7 @@
6833
6869
  <th>Reported</th>
6834
6870
  <th>Cost</th>
6835
6871
  <th>Price</th>
6872
+ <th>Markup $</th>
6836
6873
  <th>Ckpt</th>
6837
6874
  </tr>
6838
6875
  </thead>
@@ -6851,6 +6888,7 @@
6851
6888
  <td>${this._fmtTokens(it.reportedTotalTokens)}</td>
6852
6889
  <td class="debug-cost">${this._fmtCost(it.iterationCostUsd)}</td>
6853
6890
  <td class="debug-cost">${this._fmtPrice(it.iterationCustomerUsd)}</td>
6891
+ <td class="debug-cost">${this._fmtPrice(it.iterationMarkupCustomerUsd)}</td>
6854
6892
  <td>${ckpt ? ckpt.mode : '—'}</td>
6855
6893
  </tr>
6856
6894
  `;
@@ -8982,6 +9020,17 @@
8982
9020
  font-weight: 600;
8983
9021
  }
8984
9022
 
9023
+ .debug-metrics__key--sub {
9024
+ padding-left: 14px;
9025
+ font-size: 12px;
9026
+ color: rgba(0, 0, 0, 0.65);
9027
+ }
9028
+
9029
+ .debug-metrics__val--sub {
9030
+ font-size: 12px;
9031
+ color: rgba(0, 0, 0, 0.65);
9032
+ }
9033
+
8985
9034
  /* Per-iteration table (verbose). The wrapper scrolls horizontally on its own
8986
9035
  so a wide table never forces the whole drawer to scroll sideways. */
8987
9036
  .debug-iterations-scroll {