acp-kernel 0.0.53-pr.203.54 → 0.0.53

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/dist/index.js CHANGED
@@ -2909,7 +2909,7 @@ function formatTokens2(n) {
2909
2909
  }
2910
2910
  function pct(n, total) {
2911
2911
  if (n <= 0 || total <= 0) return 0;
2912
- return Math.round(n / total * 100);
2912
+ return Math.max(1, Math.round(n / total * 100));
2913
2913
  }
2914
2914
  function numericPart2(blockId) {
2915
2915
  const match = /^b(\d+)$/.exec(blockId);
@@ -2948,18 +2948,12 @@ function collectVisible(messages, state, countTokens) {
2948
2948
  if (block.active) summaryTokens += summaryTokensOf(block, countTokens);
2949
2949
  }
2950
2950
  const visible = [];
2951
- const toolCallNames = /* @__PURE__ */ new Map();
2952
- for (const message of messages) {
2953
- if (message.contentType === "tool-call" && message.toolCallId && message.toolName) {
2954
- toolCallNames.set(message.toolCallId, message.toolName);
2955
- }
2956
- }
2957
2951
  messages.forEach((message, index) => {
2958
2952
  if (coveredIds.has(message.id)) return;
2959
2953
  const ref = refForRaw(state.messageRefs, message.id);
2960
2954
  if (!ref) return;
2961
2955
  const tokens = countTokens(message.text ?? "");
2962
- const tool = isToolMessage(message) ? message.toolName ?? (message.toolCallId ? toolCallNames.get(message.toolCallId) : void 0) ?? "tool" : "text";
2956
+ const tool = message.toolName ?? "text";
2963
2957
  if (tokens > 0) visible.push({ ref, tokens, tool, index });
2964
2958
  });
2965
2959
  return { visible, summaryTokens };
@@ -3047,17 +3041,6 @@ function renderUncompressedRanges(visible) {
3047
3041
  const m = ref.match(/\d+/);
3048
3042
  return m ? parseInt(m[0], 10) : 0;
3049
3043
  };
3050
- const dominantTool = (toolTokens) => {
3051
- let best = "text";
3052
- let bestN = -1;
3053
- for (const [tool, n] of toolTokens) {
3054
- if (n > bestN) {
3055
- best = tool;
3056
- bestN = n;
3057
- }
3058
- }
3059
- return best;
3060
- };
3061
3044
  const merged = [];
3062
3045
  for (const m of visible) {
3063
3046
  const num = refNum2(m.ref);
@@ -3066,15 +3049,13 @@ function renderUncompressedRanges(visible) {
3066
3049
  last.endRef = m.ref;
3067
3050
  last.count += 1;
3068
3051
  last.tokens += m.tokens;
3069
- last.toolTokens.set(m.tool, (last.toolTokens.get(m.tool) ?? 0) + m.tokens);
3070
3052
  } else {
3071
- const toolTokens = /* @__PURE__ */ new Map([[m.tool, m.tokens]]);
3072
- merged.push({ startRef: m.ref, endRef: m.ref, startNum: num, count: 1, tokens: m.tokens, toolTokens });
3053
+ merged.push({ startRef: m.ref, endRef: m.ref, startNum: num, count: 1, tokens: m.tokens, tool: m.tool });
3073
3054
  }
3074
3055
  }
3075
3056
  for (const r of merged.slice(0, 30)) {
3076
3057
  const range = r.count === 1 ? r.startRef : `${r.startRef}\u2013${r.endRef}`;
3077
- lines.push(` ${range} (${r.count} msgs, ${formatTokens2(r.tokens)}${r.count > 1 ? ` (${Math.round(r.tokens / r.count)}/msg)` : ""}) ${dominantTool(r.toolTokens)}`);
3058
+ lines.push(` ${range} (${r.count} msgs, ${formatTokens2(r.tokens)}${r.count > 1 ? ` (${Math.round(r.tokens / r.count)}/msg)` : ""}) ${r.tool}`);
3078
3059
  }
3079
3060
  if (merged.length > 30) {
3080
3061
  lines.push(` ... and ${merged.length - 30} more ranges`);