@threadbase-sh/scanner 0.20.0 → 0.21.0

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.cjs CHANGED
@@ -513,6 +513,10 @@ function reduceLine(state, entry, tier) {
513
513
  if (type !== "user" && type !== "assistant") return;
514
514
  if (entry.isMeta) return;
515
515
  const msg = entry.message;
516
+ if (entry.isCompactSummary === true) {
517
+ if (extractTextContent(msg?.content)) state.pageMessageCount++;
518
+ return;
519
+ }
516
520
  if (state.model === null && msg?.model) state.model = msg.model;
517
521
  if (type === "user" && !state.firstUserSeen) {
518
522
  state.firstUserSeen = true;
@@ -847,8 +851,20 @@ function reduceConvLine(state, entry) {
847
851
  if (entry.lastPrompt && !state.lastPrompt) state.lastPrompt = entry.lastPrompt;
848
852
  return null;
849
853
  }
854
+ if (type === "system" && entry.subtype === "compact_boundary") {
855
+ const meta = entry.compactMetadata ?? {};
856
+ state.pendingCompaction = {
857
+ trigger: typeof meta.trigger === "string" ? meta.trigger : void 0,
858
+ preTokens: typeof meta.preTokens === "number" ? meta.preTokens : void 0,
859
+ postTokens: typeof meta.postTokens === "number" ? meta.postTokens : void 0
860
+ };
861
+ return null;
862
+ }
850
863
  if (type !== "user" && type !== "assistant") return null;
851
864
  if (entry.isMeta) return null;
865
+ const isCompactSummary = type === "user" && entry.isCompactSummary === true;
866
+ const compaction = isCompactSummary ? state.pendingCompaction : void 0;
867
+ if (isCompactSummary) delete state.pendingCompaction;
852
868
  const msg = entry.message;
853
869
  const toolUseBlocks = extractToolUseBlocks(msg?.content);
854
870
  for (const block of toolUseBlocks) state.pendingToolUses[block.id] = block;
@@ -908,7 +924,9 @@ function reduceConvLine(state, entry) {
908
924
  isSidechain: typeof entry.isSidechain === "boolean" ? entry.isSidechain : void 0,
909
925
  permissionMode: type === "user" ? entry.permissionMode : void 0,
910
926
  hasImages: hasImageBlocks(msg?.content) || void 0,
911
- attachment: entry.attachment !== void 0 ? entry.attachment : void 0
927
+ attachment: entry.attachment !== void 0 ? entry.attachment : void 0,
928
+ isCompactSummary: isCompactSummary || void 0,
929
+ compaction
912
930
  };
913
931
  }
914
932
  function parseJsonlLine(line, state = initialConvState()) {
@@ -2600,7 +2618,7 @@ function extractCursorSearchText(content) {
2600
2618
  function extractClaudeDelta(entry) {
2601
2619
  const type = entry.type;
2602
2620
  if (type !== "user" && type !== "assistant") return emptySearchDocument();
2603
- if (entry.isMeta) return emptySearchDocument();
2621
+ if (entry.isMeta || entry.isCompactSummary === true) return emptySearchDocument();
2604
2622
  const msg = entry.message;
2605
2623
  const content = msg?.content;
2606
2624
  const tools = [