@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.js CHANGED
@@ -432,6 +432,10 @@ function reduceLine(state, entry, tier) {
432
432
  if (type !== "user" && type !== "assistant") return;
433
433
  if (entry.isMeta) return;
434
434
  const msg = entry.message;
435
+ if (entry.isCompactSummary === true) {
436
+ if (extractTextContent(msg?.content)) state.pageMessageCount++;
437
+ return;
438
+ }
435
439
  if (state.model === null && msg?.model) state.model = msg.model;
436
440
  if (type === "user" && !state.firstUserSeen) {
437
441
  state.firstUserSeen = true;
@@ -766,8 +770,20 @@ function reduceConvLine(state, entry) {
766
770
  if (entry.lastPrompt && !state.lastPrompt) state.lastPrompt = entry.lastPrompt;
767
771
  return null;
768
772
  }
773
+ if (type === "system" && entry.subtype === "compact_boundary") {
774
+ const meta = entry.compactMetadata ?? {};
775
+ state.pendingCompaction = {
776
+ trigger: typeof meta.trigger === "string" ? meta.trigger : void 0,
777
+ preTokens: typeof meta.preTokens === "number" ? meta.preTokens : void 0,
778
+ postTokens: typeof meta.postTokens === "number" ? meta.postTokens : void 0
779
+ };
780
+ return null;
781
+ }
769
782
  if (type !== "user" && type !== "assistant") return null;
770
783
  if (entry.isMeta) return null;
784
+ const isCompactSummary = type === "user" && entry.isCompactSummary === true;
785
+ const compaction = isCompactSummary ? state.pendingCompaction : void 0;
786
+ if (isCompactSummary) delete state.pendingCompaction;
771
787
  const msg = entry.message;
772
788
  const toolUseBlocks = extractToolUseBlocks(msg?.content);
773
789
  for (const block of toolUseBlocks) state.pendingToolUses[block.id] = block;
@@ -827,7 +843,9 @@ function reduceConvLine(state, entry) {
827
843
  isSidechain: typeof entry.isSidechain === "boolean" ? entry.isSidechain : void 0,
828
844
  permissionMode: type === "user" ? entry.permissionMode : void 0,
829
845
  hasImages: hasImageBlocks(msg?.content) || void 0,
830
- attachment: entry.attachment !== void 0 ? entry.attachment : void 0
846
+ attachment: entry.attachment !== void 0 ? entry.attachment : void 0,
847
+ isCompactSummary: isCompactSummary || void 0,
848
+ compaction
831
849
  };
832
850
  }
833
851
  function parseJsonlLine(line, state = initialConvState()) {
@@ -2519,7 +2537,7 @@ function extractCursorSearchText(content) {
2519
2537
  function extractClaudeDelta(entry) {
2520
2538
  const type = entry.type;
2521
2539
  if (type !== "user" && type !== "assistant") return emptySearchDocument();
2522
- if (entry.isMeta) return emptySearchDocument();
2540
+ if (entry.isMeta || entry.isCompactSummary === true) return emptySearchDocument();
2523
2541
  const msg = entry.message;
2524
2542
  const content = msg?.content;
2525
2543
  const tools = [