@kodaris/krubble-app-components 1.0.167 → 1.0.168

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