@kodaris/krubble-app-components 1.0.165 → 1.0.167

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.
@@ -3674,6 +3674,28 @@ class KRChatbot extends i$3 {
3674
3674
  this._inputValue = payload.message;
3675
3675
  this._handleSubmit();
3676
3676
  }
3677
+ /**
3678
+ * Open the panel and place `payload.message` in the composer, selected, without sending it.
3679
+ *
3680
+ * For a host app that wants to suggest an opening message rather than send one (e.g. a site
3681
+ * editor deep link): Enter sends it as is, typing replaces it. Nothing is persisted beyond the
3682
+ * composer draft state any typed text gets.
3683
+ */
3684
+ draft(payload) {
3685
+ this.open();
3686
+ this._inputValue = payload.message;
3687
+ this._saveState();
3688
+ // Same delay as the open-focus in `updated`: the panel has to finish showing before the
3689
+ // textarea can take focus, and this has to run after that focus so the selection sticks.
3690
+ this.updateComplete.then(() => {
3691
+ setTimeout(() => {
3692
+ if (this._inputEl) {
3693
+ this._inputEl.focus();
3694
+ this._inputEl.select();
3695
+ }
3696
+ }, 200);
3697
+ });
3698
+ }
3677
3699
  // --- Private methods ---
3678
3700
  /**
3679
3701
  * Shows a full-viewport transparent overlay during drag/resize operations.
@@ -6364,6 +6386,19 @@ class KRChatbot extends i$3 {
6364
6386
  }
6365
6387
  return '~$' + n.toFixed(4);
6366
6388
  }
6389
+ _fmtPrice(n) {
6390
+ if (n == null || isNaN(n)) {
6391
+ return '—';
6392
+ }
6393
+ return '$' + n.toFixed(2);
6394
+ }
6395
+ _getCustomerPriceLabel() {
6396
+ const rate = this._telemetry?.customerPricePerThousandTokens;
6397
+ if (rate == null || isNaN(rate)) {
6398
+ return 'Customer price';
6399
+ }
6400
+ return `Customer price ($${rate}/1K)`;
6401
+ }
6367
6402
  /**
6368
6403
  * INTERNAL-ONLY debug telemetry panel. Rendered only in the inline variant
6369
6404
  * (guarded by the caller) and only when the user has toggled it open. Shows
@@ -6744,8 +6779,14 @@ class KRChatbot extends i$3 {
6744
6779
  <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.turnCacheReadTokens)}</span>
6745
6780
  <span class="debug-metrics__key">Hit rate</span>
6746
6781
  <span class="debug-metrics__val">${this._telemetry.turnHitRate ?? '—'}%</span>
6782
+ <span class="debug-metrics__key">Total tokens</span>
6783
+ <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.turnTotalTokens)}</span>
6784
+ <span class="debug-metrics__key">Reported total</span>
6785
+ <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.turnReportedTotalTokens)}</span>
6747
6786
  <span class="debug-metrics__key">Cost</span>
6748
6787
  <span class="debug-metrics__val debug-cost">${this._fmtCost(this._telemetry.turnCostUsd)}</span>
6788
+ <span class="debug-metrics__key">${this._getCustomerPriceLabel()}</span>
6789
+ <span class="debug-metrics__val debug-cost">${this._fmtPrice(this._telemetry.turnCustomerUsd)}</span>
6749
6790
  </div>
6750
6791
  </div>
6751
6792
 
@@ -6760,8 +6801,12 @@ class KRChatbot extends i$3 {
6760
6801
  <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.conversationCacheReadTokens)}</span>
6761
6802
  <span class="debug-metrics__key">Cache write</span>
6762
6803
  <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.conversationCacheWriteTokens)}</span>
6804
+ <span class="debug-metrics__key">Total tokens</span>
6805
+ <span class="debug-metrics__val">${this._fmtTokens(this._telemetry.conversationTotalTokens)}</span>
6763
6806
  <span class="debug-metrics__key">Cost so far</span>
6764
6807
  <span class="debug-metrics__val debug-cost">${this._fmtCost(this._telemetry.conversationCostUsd)}</span>
6808
+ <span class="debug-metrics__key">${this._getCustomerPriceLabel()} so far</span>
6809
+ <span class="debug-metrics__val debug-cost">${this._fmtPrice(this._telemetry.conversationCustomerUsd)}</span>
6765
6810
  </div>
6766
6811
  </div>
6767
6812
  ` : b `
@@ -6781,7 +6826,10 @@ class KRChatbot extends i$3 {
6781
6826
  <th>Cache R</th>
6782
6827
  <th>Cache W</th>
6783
6828
  <th>Hit</th>
6829
+ <th>Total</th>
6830
+ <th>Reported</th>
6784
6831
  <th>Cost</th>
6832
+ <th>Price</th>
6785
6833
  <th>Ckpt</th>
6786
6834
  </tr>
6787
6835
  </thead>
@@ -6796,7 +6844,10 @@ class KRChatbot extends i$3 {
6796
6844
  <td>${this._fmtTokens(it.iterationCacheRead)}</td>
6797
6845
  <td>${this._fmtTokens(it.iterationCacheWrite)}</td>
6798
6846
  <td>${it.iterationHitRate ?? '—'}%</td>
6847
+ <td>${this._fmtTokens(it.iterationTotalTokens)}</td>
6848
+ <td>${this._fmtTokens(it.reportedTotalTokens)}</td>
6799
6849
  <td class="debug-cost">${this._fmtCost(it.iterationCostUsd)}</td>
6850
+ <td class="debug-cost">${this._fmtPrice(it.iterationCustomerUsd)}</td>
6800
6851
  <td>${ckpt ? ckpt.mode : '—'}</td>
6801
6852
  </tr>
6802
6853
  `;