@cchistory/lite 0.6.0 → 0.7.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.
Files changed (150) hide show
  1. package/INSTALL.md +1 -1
  2. package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
  3. package/apps/lite-cli/dist/agent-contract.js +12 -5
  4. package/apps/lite-cli/dist/agent-contract.js.map +1 -1
  5. package/apps/lite-cli/dist/agent-journeys.test.d.ts +2 -0
  6. package/apps/lite-cli/dist/agent-journeys.test.d.ts.map +1 -0
  7. package/apps/lite-cli/dist/agent-journeys.test.js +403 -0
  8. package/apps/lite-cli/dist/agent-journeys.test.js.map +1 -0
  9. package/apps/lite-cli/dist/index.d.ts.map +1 -1
  10. package/apps/lite-cli/dist/index.js +51 -13
  11. package/apps/lite-cli/dist/index.js.map +1 -1
  12. package/apps/lite-cli/dist/index.test.js +16 -5
  13. package/apps/lite-cli/dist/index.test.js.map +1 -1
  14. package/apps/lite-cli/dist/query.d.ts +15 -2
  15. package/apps/lite-cli/dist/query.d.ts.map +1 -1
  16. package/apps/lite-cli/dist/query.js +79 -4
  17. package/apps/lite-cli/dist/query.js.map +1 -1
  18. package/apps/lite-cli/dist/shell.d.ts +2 -1
  19. package/apps/lite-cli/dist/shell.d.ts.map +1 -1
  20. package/apps/lite-cli/dist/shell.js +20 -16
  21. package/apps/lite-cli/dist/shell.js.map +1 -1
  22. package/apps/lite-cli/dist/version.d.ts +1 -1
  23. package/apps/lite-cli/dist/version.js +1 -1
  24. package/apps/lite-tui/dist/model.d.ts.map +1 -1
  25. package/apps/lite-tui/dist/model.js +2 -1
  26. package/apps/lite-tui/dist/model.js.map +1 -1
  27. package/apps/lite-tui/dist/render.d.ts +1 -1
  28. package/apps/lite-tui/dist/version.d.ts +1 -1
  29. package/apps/lite-tui/dist/version.js +1 -1
  30. package/docs/guide/agent-evidence.md +154 -0
  31. package/docs/guide/for-agents.md +29 -10
  32. package/docs/guide/lite.md +8 -0
  33. package/docs/guide/query.md +10 -1
  34. package/node_modules/@cchistory/canonical/dist/conversation-evidence.d.ts +85 -0
  35. package/node_modules/@cchistory/canonical/dist/conversation-evidence.d.ts.map +1 -0
  36. package/node_modules/@cchistory/canonical/dist/conversation-evidence.js +191 -0
  37. package/node_modules/@cchistory/canonical/dist/conversation-evidence.js.map +1 -0
  38. package/node_modules/@cchistory/canonical/dist/conversation-evidence.test.d.ts +2 -0
  39. package/node_modules/@cchistory/canonical/dist/conversation-evidence.test.d.ts.map +1 -0
  40. package/node_modules/@cchistory/canonical/dist/conversation-evidence.test.js +105 -0
  41. package/node_modules/@cchistory/canonical/dist/conversation-evidence.test.js.map +1 -0
  42. package/node_modules/@cchistory/canonical/dist/index.d.ts +2 -0
  43. package/node_modules/@cchistory/canonical/dist/index.d.ts.map +1 -1
  44. package/node_modules/@cchistory/canonical/dist/index.js +2 -0
  45. package/node_modules/@cchistory/canonical/dist/index.js.map +1 -1
  46. package/node_modules/@cchistory/canonical/dist/projection-audit.d.ts +4 -3
  47. package/node_modules/@cchistory/canonical/dist/projection-audit.d.ts.map +1 -1
  48. package/node_modules/@cchistory/canonical/dist/projection-audit.js +14 -0
  49. package/node_modules/@cchistory/canonical/dist/projection-audit.js.map +1 -1
  50. package/node_modules/@cchistory/canonical/dist/read-status.d.ts +11 -0
  51. package/node_modules/@cchistory/canonical/dist/read-status.d.ts.map +1 -0
  52. package/node_modules/@cchistory/canonical/dist/read-status.js +14 -0
  53. package/node_modules/@cchistory/canonical/dist/read-status.js.map +1 -0
  54. package/node_modules/@cchistory/canonical/dist/session-family.js +1 -1
  55. package/node_modules/@cchistory/canonical/dist/session-family.js.map +1 -1
  56. package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts +7 -3
  57. package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts.map +1 -1
  58. package/node_modules/@cchistory/canonical/dist/session-interpreter.js +15 -13
  59. package/node_modules/@cchistory/canonical/dist/session-interpreter.js.map +1 -1
  60. package/node_modules/@cchistory/canonical/package.json +1 -1
  61. package/node_modules/@cchistory/domain/dist/conversation-evidence.d.ts +24 -0
  62. package/node_modules/@cchistory/domain/dist/conversation-evidence.d.ts.map +1 -0
  63. package/node_modules/@cchistory/domain/dist/conversation-evidence.js +2 -0
  64. package/node_modules/@cchistory/domain/dist/conversation-evidence.js.map +1 -0
  65. package/node_modules/@cchistory/domain/dist/index.d.ts +5 -0
  66. package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -1
  67. package/node_modules/@cchistory/domain/dist/index.js.map +1 -1
  68. package/node_modules/@cchistory/domain/package.json +1 -1
  69. package/node_modules/@cchistory/live-runtime/dist/bounded-cache.d.ts +15 -0
  70. package/node_modules/@cchistory/live-runtime/dist/bounded-cache.d.ts.map +1 -0
  71. package/node_modules/@cchistory/live-runtime/dist/bounded-cache.js +44 -0
  72. package/node_modules/@cchistory/live-runtime/dist/bounded-cache.js.map +1 -0
  73. package/node_modules/@cchistory/live-runtime/dist/bounded-cache.test.d.ts +2 -0
  74. package/node_modules/@cchistory/live-runtime/dist/bounded-cache.test.d.ts.map +1 -0
  75. package/node_modules/@cchistory/live-runtime/dist/bounded-cache.test.js +45 -0
  76. package/node_modules/@cchistory/live-runtime/dist/bounded-cache.test.js.map +1 -0
  77. package/node_modules/@cchistory/live-runtime/dist/diagnostics.d.ts +7 -0
  78. package/node_modules/@cchistory/live-runtime/dist/diagnostics.d.ts.map +1 -0
  79. package/node_modules/@cchistory/live-runtime/dist/diagnostics.js +2 -0
  80. package/node_modules/@cchistory/live-runtime/dist/diagnostics.js.map +1 -0
  81. package/node_modules/@cchistory/live-runtime/dist/history-reader.d.ts +24 -0
  82. package/node_modules/@cchistory/live-runtime/dist/history-reader.d.ts.map +1 -0
  83. package/node_modules/@cchistory/live-runtime/dist/history-reader.js +155 -0
  84. package/node_modules/@cchistory/live-runtime/dist/history-reader.js.map +1 -0
  85. package/node_modules/@cchistory/live-runtime/dist/index.d.ts +91 -5
  86. package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -1
  87. package/node_modules/@cchistory/live-runtime/dist/index.js +186 -57
  88. package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -1
  89. package/node_modules/@cchistory/live-runtime/dist/index.test.js +6 -1
  90. package/node_modules/@cchistory/live-runtime/dist/index.test.js.map +1 -1
  91. package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts +2 -1
  92. package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts.map +1 -1
  93. package/node_modules/@cchistory/live-runtime/dist/selective-query.js.map +1 -1
  94. package/node_modules/@cchistory/live-runtime/package.json +1 -1
  95. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.d.ts +3 -0
  96. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.d.ts.map +1 -1
  97. package/node_modules/@cchistory/source-adapters/dist/core/conversation-seeds.js.map +1 -1
  98. package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.d.ts +12 -0
  99. package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.d.ts.map +1 -0
  100. package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.js +32 -0
  101. package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.js.map +1 -0
  102. package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.test.d.ts +2 -0
  103. package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.test.d.ts.map +1 -0
  104. package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.test.js +21 -0
  105. package/node_modules/@cchistory/source-adapters/dist/core/decoded-record.test.js.map +1 -0
  106. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.d.ts +3 -1
  107. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.d.ts.map +1 -1
  108. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.js +56 -38
  109. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.js.map +1 -1
  110. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.test.js +46 -1
  111. package/node_modules/@cchistory/source-adapters/dist/core/jsonl-records.test.js.map +1 -1
  112. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts +15 -4
  113. package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -1
  114. package/node_modules/@cchistory/source-adapters/dist/core/parser.js +110 -69
  115. package/node_modules/@cchistory/source-adapters/dist/core/parser.js.map +1 -1
  116. package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts.map +1 -1
  117. package/node_modules/@cchistory/source-adapters/dist/core/probe.js +68 -30
  118. package/node_modules/@cchistory/source-adapters/dist/core/probe.js.map +1 -1
  119. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts +4 -1
  120. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts.map +1 -1
  121. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js +4 -2
  122. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js.map +1 -1
  123. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js +58 -0
  124. package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js.map +1 -1
  125. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts +6 -2
  126. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts.map +1 -1
  127. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js +5 -5
  128. package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js.map +1 -1
  129. package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts +4 -1
  130. package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts.map +1 -1
  131. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +1 -0
  132. package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -1
  133. package/node_modules/@cchistory/source-adapters/dist/index.test.js +1 -0
  134. package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
  135. package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js +49 -1
  136. package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js.map +1 -1
  137. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts +2 -0
  138. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts.map +1 -1
  139. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js +48 -29
  140. package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js.map +1 -1
  141. package/node_modules/@cchistory/source-adapters/package.json +1 -1
  142. package/package.json +5 -5
  143. package/schemas/cchistory-lite-agent-v1.schema.json +8 -5
  144. package/schemas/cchistory-lite-canonical-v1.schema.json +82 -0
  145. package/schemas/cchistory-lite-diagnostic-v1.schema.json +27 -0
  146. package/schemas/cchistory-lite-query-result-v2.schema.json +232 -4
  147. package/schemas/cchistory-lite-query-result-v3.schema.json +45 -1
  148. package/schemas/cchistory-lite-query-v2.schema.json +150 -8
  149. package/schemas/cchistory-lite-v2.schema.json +82 -0
  150. package/skills/using-cchistory-lite/SKILL.md +86 -128
@@ -9,7 +9,7 @@ import { isAntigravityBrainSourceFile, isAntigravityHistoryIndexFile } from "../
9
9
  import { extractCursorChatStoreSeed, clearCursorWorkspaceIndexCache } from "../platforms/cursor/runtime.js";
10
10
  import { getPlatformAdapter } from "../platforms/registry.js";
11
11
  import { deriveSourceFileLogicalSessionKey, inspectSourceFileLogicalSessionMetadata, SESSION_METADATA_MAX_LINE_BYTES, } from "./session-grouping.js";
12
- import { extractRecords, extractMultiSessionSeeds, buildAdapterBlobResult, captureBlob, captureBlobStreaming, fileIdentityFromStats, parseRecord, isOrdinaryResumeEligibleSourceFile, extractGenericSessionMetadata, extractGenericRole, extractGenericContentItems, extractRichTextText, collectConversationSeedsFromValue, dedupeClaudeCodeTokenUsageFragments, } from "./parser.js";
12
+ import { extractRecords, extractMultiSessionSeeds, iterateZcodeSeeds, buildAdapterBlobResult, createAdapterBlobBuilder, captureBlob, captureBlobStreaming, fileIdentityFromStats, parseRecord, isOrdinaryResumeEligibleSourceFile, extractGenericSessionMetadata, extractGenericRole, extractGenericContentItems, extractRichTextText, collectConversationSeedsFromValue, dedupeClaudeCodeTokenUsageFragments, } from "./parser.js";
13
13
  import { collectJsonlRecordsStreaming, isIncrementalJsonlPlatform } from "./jsonl-records.js";
14
14
  import { atomizeFragments, hydrateDraftFromAtoms } from "./atomizer.js";
15
15
  import { splitUserText } from "./user-text.js";
@@ -121,11 +121,14 @@ async function finalizeSourcePayload(interpretSession, state, host, options) {
121
121
  message: `Deriving projections from ${state.sessionsById.size} session candidate(s)`,
122
122
  });
123
123
  const deriveStartedAt = Date.now();
124
- const processingCore = await processCollectedSessions(interpretSession, state.sessionsById, state.orphanBlobs, state.lossAudits, { safeMode: options.safe_mode ?? false });
124
+ const processingCore = await processCollectedSessions(interpretSession, state.sessionsById, state.orphanBlobs, state.lossAudits, { safeMode: options.safe_mode ?? false, retainRawRecords: options.retain_raw_records !== false,
125
+ onInterpretedSession: count => emitProbeProgress(options, state.source, { stage: "derive_progress", count, count_unit: "sessions" }),
126
+ });
125
127
  emitProbeProgress(options, state.source, {
126
128
  stage: "derive_done",
127
129
  message: `Derived ${processingCore.sessions.length} session(s), ${processingCore.turns.length} turn(s)`,
128
130
  count: processingCore.turns.length,
131
+ count_unit: "turns",
129
132
  elapsed_ms: Date.now() - deriveStartedAt,
130
133
  });
131
134
  const uniqueBlobs = dedupeById(processingCore.blobs);
@@ -182,6 +185,7 @@ async function finalizeSourcePayload(interpretSession, state, host, options) {
182
185
  stage: "source_done",
183
186
  message: `Finished ${state.source.display_name}`,
184
187
  count: processingCore.turns.length,
188
+ count_unit: "turns",
185
189
  elapsed_ms: Date.now() - state.monotonicStartedAt,
186
190
  });
187
191
  return payload;
@@ -294,7 +298,9 @@ export async function projectFileSessionInputs(interpretSession, source, session
294
298
  async function* streamCollectedFileInputs(source, host, sourceFormatProfile, options, startedAt) {
295
299
  const captureRunId = stableId("capture-run", source.id, startedAt);
296
300
  const adapter = getPlatformAdapter(source.platform);
297
- const previousIndex = buildPreviousSourceIndex(options.previous_payloads?.[source.id], sourceFormatProfile);
301
+ const previousPayload = options.previous_payloads?.[source.id];
302
+ const previousIndex = previousPayload?.records.some(record => record.raw_text_retained === false)
303
+ ? undefined : buildPreviousSourceIndex(previousPayload, sourceFormatProfile);
298
304
  const changedSinceMs = parseChangedSinceMs(options.changed_since);
299
305
  const capturedCompanionPaths = new Set();
300
306
  let remainingFileLimit = options.limit_files_per_source;
@@ -329,6 +335,7 @@ async function* streamCollectedFileInputs(source, host, sourceFormatProfile, opt
329
335
  stage: "live_probe_done",
330
336
  message: `Collected ${liveCollection?.virtualPaths.length ?? 0} live item(s)`,
331
337
  count: liveCollection?.virtualPaths.length ?? 0,
338
+ count_unit: "files",
332
339
  });
333
340
  }
334
341
  emitProbeProgress(options, source, {
@@ -348,6 +355,7 @@ async function* streamCollectedFileInputs(source, host, sourceFormatProfile, opt
348
355
  stage: "list_files_done",
349
356
  message: `Found ${files.length} source file(s)`,
350
357
  count: files.length,
358
+ count_unit: "files",
351
359
  file_count: files.length,
352
360
  elapsed_ms: Date.now() - listFilesStartedAt,
353
361
  });
@@ -383,9 +391,13 @@ async function* streamSingleFileInputs(source, host, sourceFormatProfile, option
383
391
  const isOversized = sizeBytes > maxFileBytes;
384
392
  // Oversized files are skipped only when parsing needs the whole file in
385
393
  // memory. Incremental JSONL streams; path-backed SQLite is opened by path.
386
- const canProcessOversizedWithoutMaterializing = isOversized &&
394
+ const canProcessOversizedWithoutMaterializing = (isOversized || options.retain_raw_records === false &&
395
+ (sizeBytes > 8 * 1024 * 1024 || sizeBytes > (options.read_budget?.maximumUnitBytes?.() ?? Infinity))) &&
387
396
  (isIncrementalJsonlPlatform(source.platform) || isPathBackedSqliteSourceFile(source.platform, filePath));
388
- if (isOversized && !canProcessOversizedWithoutMaterializing) {
397
+ // An explicit cap remains binding. Guarded whole-file readers already price
398
+ // the actual allocation against live headroom; the fallback cap is not RAM capacity.
399
+ const hasAllocationAdmission = options.max_file_bytes === undefined && options.read_budget?.maximumUnitBytes !== undefined;
400
+ if (isOversized && !canProcessOversizedWithoutMaterializing && !hasAllocationAdmission) {
389
401
  const detail = `Skipped oversized source file ${filePath}: ${sizeBytes} bytes exceeds ${maxFileBytes} byte limit`;
390
402
  const blobRef = stableId("blob", source.id, filePath, "oversized");
391
403
  fileLossAudits.push(createLossAudit(source.id, blobRef, "unknown_fragment", detail, {
@@ -444,7 +456,7 @@ async function* streamSingleFileInputs(source, host, sourceFormatProfile, option
444
456
  capturedBlob = isPathBackedSqliteSourceFile(source.platform, filePath)
445
457
  ? await capturePathBackedBlob(source, host.id, filePath, captureRunId)
446
458
  : canProcessOversizedWithoutMaterializing
447
- ? await captureBlobStreaming(source, host.id, filePath, captureRunId, options.read_budget)
459
+ ? await captureBlobStreaming(source, host.id, filePath, captureRunId, options.read_budget, options.retain_raw_records === false)
448
460
  : await captureBlob(source, host.id, filePath, captureRunId, options.read_budget);
449
461
  emitProbeProgress(options, source, {
450
462
  stage: "file_capture_done",
@@ -572,10 +584,10 @@ async function* streamSingleFileInputs(source, host, sourceFormatProfile, option
572
584
  }
573
585
  const adapterResults = appendedResults ?? (capturedBlob
574
586
  ? (capturedBlobHasFileBuffer(capturedBlob)
575
- ? await processBlob(source, sourceFormatProfile, filePath, capturedBlob, options.target_session_refs, options.read_budget)
587
+ ? await processBlob(source, sourceFormatProfile, filePath, capturedBlob, options.target_session_refs, options.read_budget, options.retain_raw_records !== false)
576
588
  : capturedBlobIsStreaming(capturedBlob)
577
- ? await processStreamingJsonlBlob(source, sourceFormatProfile, filePath, capturedBlob)
578
- : await processPathBackedSqliteBlob(source, sourceFormatProfile, filePath, capturedBlob.blob, options.target_session_refs, options.read_budget))
589
+ ? await processStreamingJsonlBlob(source, sourceFormatProfile, filePath, capturedBlob, options)
590
+ : await processPathBackedSqliteBlob(source, sourceFormatProfile, filePath, capturedBlob.blob, options.target_session_refs, options.read_budget, options.retain_raw_records !== false, count => emitProbeProgress(options, source, { stage: "file_parse_progress", file_path: filePath, count, count_unit: "sessions" })))
579
591
  : []);
580
592
  const sessionsById = new Map();
581
593
  const targetedResults = options.target_session_refs?.length
@@ -1534,6 +1546,11 @@ async function processCollectedSessions(interpretSession, sessionsById, orphanBl
1534
1546
  }
1535
1547
  }
1536
1548
  for (const sessionInput of sessionsById.values()) {
1549
+ if (options.retainRawRecords === false) {
1550
+ sessionInput.records = sessionInput.records.map(record => record.raw_text_retained === false ? record : {
1551
+ ...record, raw_size_bytes: Buffer.byteLength(record.raw_json, "utf8"), raw_json: "", raw_text_retained: false,
1552
+ });
1553
+ }
1537
1554
  sessionInput.atoms.sort(compareTimeThenSeq);
1538
1555
  if (sessionInput.draft.source_platform === "antigravity") {
1539
1556
  sessionInput.atoms = collapseAntigravityUserTurnAtoms(sessionInput.atoms);
@@ -1555,6 +1572,7 @@ async function processCollectedSessions(interpretSession, sessionsById, orphanBl
1555
1572
  askUserQuestionTurns.push(...buildAskUserQuestionTurns(sessionInput.draft, sessionInput.atoms, sessionInput.edges));
1556
1573
  }
1557
1574
  lossAudits.push(...sessionInput.loss_audits);
1575
+ options.onInterpretedSession?.(sessions.length);
1558
1576
  }
1559
1577
  blobs.push(...orphanBlobs);
1560
1578
  lossAudits.push(...sourceLossAudits);
@@ -1581,10 +1599,10 @@ function emitProbeProgress(options, source, event) {
1581
1599
  ...event,
1582
1600
  });
1583
1601
  }
1584
- async function processPathBackedSqliteBlob(source, sourceFormatProfile, filePath, blob, targetSessionRefs, budget) {
1585
- return (await tryProcessPathOpenedContainer(source, sourceFormatProfile, filePath, blob, Buffer.alloc(0), targetSessionRefs, budget)) ?? [];
1602
+ async function processPathBackedSqliteBlob(source, sourceFormatProfile, filePath, blob, targetSessionRefs, budget, retainRawRecords = true, onSession) {
1603
+ return (await tryProcessPathOpenedContainer(source, sourceFormatProfile, filePath, blob, Buffer.alloc(0), targetSessionRefs, budget, retainRawRecords, onSession)) ?? [];
1586
1604
  }
1587
- async function tryProcessPathOpenedContainer(source, sourceFormatProfile, filePath, blob, fileBuffer, targetSessionRefs, budget) {
1605
+ async function tryProcessPathOpenedContainer(source, sourceFormatProfile, filePath, blob, fileBuffer, targetSessionRefs, budget, retainRawRecords = true, onSession) {
1588
1606
  const blobId = blob.id;
1589
1607
  if (source.platform === "cursor" && path.basename(filePath) === "store.db") {
1590
1608
  const chatStoreSeed = await extractCursorChatStoreSeed(source.platform, filePath, blob.file_modified_at ?? nowIso(), {
@@ -1640,12 +1658,16 @@ async function tryProcessPathOpenedContainer(source, sourceFormatProfile, filePa
1640
1658
  }
1641
1659
  return [];
1642
1660
  }
1643
- const multiSessionSeeds = await extractMultiSessionSeeds(source, filePath, fileBuffer, blobId, targetSessionRefs, budget);
1661
+ const multiSessionSeeds = source.platform === "zcode"
1662
+ ? iterateZcodeSeeds(source, filePath, targetSessionRefs, budget, retainRawRecords)
1663
+ : await extractMultiSessionSeeds(source, filePath, fileBuffer, blobId, targetSessionRefs, budget);
1644
1664
  if (!multiSessionSeeds) {
1645
1665
  return undefined;
1646
1666
  }
1647
1667
  const results = [];
1648
- for (const seed of multiSessionSeeds.filter((entry) => !targetSessionRefs?.length || targetSessionRefs.some((ref) => targetRefMatchesSession(ref, entry.sessionId)))) {
1668
+ for (const seed of multiSessionSeeds) {
1669
+ if (targetSessionRefs?.length && !targetSessionRefs.some(ref => targetRefMatchesSession(ref, seed.sessionId)))
1670
+ continue;
1649
1671
  results.push(buildAdapterBlobResult(source, sourceFormatProfile, blob.host_id, filePath, blob.capture_run_id, blob, seed.sessionId, seed.records.map((record, ordinal) => ({
1650
1672
  id: stableId("record", source.id, seed.sessionId, blobId, String(ordinal), record.pointer),
1651
1673
  source_id: source.id,
@@ -1656,17 +1678,20 @@ async function tryProcessPathOpenedContainer(source, sourceFormatProfile, filePa
1656
1678
  observed_at: record.observedAt ?? nowIso(),
1657
1679
  parseable: true,
1658
1680
  raw_json: record.rawJson,
1681
+ ...(record.parsedValue ? { parsed_value: record.parsedValue, raw_size_bytes: record.rawSizeBytes,
1682
+ raw_text_retained: false } : {}),
1659
1683
  })), {
1660
1684
  title: seed.title,
1661
1685
  created_at: seed.createdAt,
1662
1686
  updated_at: seed.updatedAt,
1663
1687
  model: seed.model,
1664
1688
  working_directory: seed.workingDirectory,
1665
- }));
1689
+ }, [], retainRawRecords));
1690
+ onSession?.(results.length);
1666
1691
  }
1667
1692
  return results;
1668
1693
  }
1669
- async function processBlob(source, sourceFormatProfile, filePath, capturedBlob, targetSessionRefs, budget) {
1694
+ async function processBlob(source, sourceFormatProfile, filePath, capturedBlob, targetSessionRefs, budget, retainRawRecords = true) {
1670
1695
  const { blob, fileBuffer } = capturedBlob;
1671
1696
  const pathOpened = await tryProcessPathOpenedContainer(source, sourceFormatProfile, filePath, blob, fileBuffer, targetSessionRefs, budget);
1672
1697
  if (pathOpened) {
@@ -1674,7 +1699,16 @@ async function processBlob(source, sourceFormatProfile, filePath, capturedBlob,
1674
1699
  }
1675
1700
  const blobId = blob.id;
1676
1701
  const profileId = sourceFormatProfile.id;
1677
- const sessionId = deriveSessionId(source.platform, filePath, fileBuffer);
1702
+ let decodedRoot;
1703
+ if (source.platform === "amp") {
1704
+ try {
1705
+ decodedRoot = { value: JSON.parse(fileBuffer.toString("utf8")) };
1706
+ }
1707
+ catch {
1708
+ decodedRoot = { value: undefined };
1709
+ }
1710
+ }
1711
+ const sessionId = deriveSessionId(source.platform, filePath, fileBuffer, decodedRoot);
1678
1712
  if (targetSessionRefs?.length &&
1679
1713
  source.platform !== "codex" &&
1680
1714
  !targetSessionRefs.some((ref) => targetRefMatchesSession(ref, sessionId)) &&
@@ -1689,7 +1723,7 @@ async function processBlob(source, sourceFormatProfile, filePath, capturedBlob,
1689
1723
  sessionId,
1690
1724
  captureRunId: blob.capture_run_id,
1691
1725
  };
1692
- const records = await extractRecords(context, blobId, fileBuffer);
1726
+ const records = await extractRecords(context, blobId, fileBuffer, retainRawRecords, decodedRoot);
1693
1727
  const extractionLossAudits = [];
1694
1728
  if (records.length === 0) {
1695
1729
  extractionLossAudits.push(createLossAudit(source.id, blobId, "dropped_for_projection", "Blob was captured but produced no raw records", {
@@ -1729,26 +1763,30 @@ async function processBlob(source, sourceFormatProfile, filePath, capturedBlob,
1729
1763
  // captured from file identity (metadata-only) and opened by path via
1730
1764
  // processPathBackedSqliteBlob instead of being hashed into memory.
1731
1765
  // AMP root-JSON, Gemini, and other non-JSONL shapes still take the oversized skip.
1732
- async function processStreamingJsonlBlob(source, sourceFormatProfile, filePath, capturedBlob) {
1766
+ async function processStreamingJsonlBlob(source, sourceFormatProfile, filePath, capturedBlob, options = {}) {
1733
1767
  const { blob } = capturedBlob;
1734
1768
  const blobId = blob.id;
1735
1769
  const profileId = sourceFormatProfile.id;
1736
1770
  const head = await capturedBlob.prefixReader(SESSION_METADATA_MAX_LINE_BYTES);
1737
1771
  const sessionId = deriveSessionId(source.platform, filePath, head);
1738
- const context = {
1739
- source,
1740
- hostId: blob.host_id,
1741
- filePath,
1742
- profileId,
1743
- sessionId,
1744
- captureRunId: blob.capture_run_id,
1745
- };
1772
+ const builder = createAdapterBlobBuilder(source, sourceFormatProfile, blob.host_id, filePath, blob.capture_run_id, blob, sessionId, {}, [], options.retain_raw_records !== false);
1773
+ let parsedRecords = 0;
1746
1774
  const records = await collectJsonlRecordsStreaming(capturedBlob.streamingLineReader(), {
1747
1775
  sourceId: source.id,
1748
1776
  blobId,
1749
1777
  sessionId,
1750
1778
  }, {
1751
1779
  observedAt: nowIso(),
1780
+ transformRecord: record => {
1781
+ const retained = builder.append(record);
1782
+ if (++parsedRecords % 256 === 0)
1783
+ emitProbeProgress(options, source, {
1784
+ stage: "file_parse_progress", file_path: filePath, count: parsedRecords, count_unit: "records",
1785
+ });
1786
+ return retained;
1787
+ },
1788
+ admitLineBytes: options.retain_raw_records === false
1789
+ ? bytes => options.read_budget?.admit(bytes, `${filePath}:JSONL record`) : undefined,
1752
1790
  sidecars: source.platform === "factory_droid"
1753
1791
  ? [
1754
1792
  {
@@ -1788,9 +1826,9 @@ async function processStreamingJsonlBlob(source, sourceFormatProfile, filePath,
1788
1826
  sourceFormatProfileId: profileId,
1789
1827
  }));
1790
1828
  }
1791
- return [
1792
- buildAdapterBlobResult(source, sourceFormatProfile, blob.host_id, filePath, blob.capture_run_id, blob, sessionId, records, {}, extractionLossAudits),
1793
- ];
1829
+ const result = builder.finish();
1830
+ result.loss_audits.push(...extractionLossAudits);
1831
+ return [result];
1794
1832
  }
1795
1833
  function buildSyntheticSeedAdapterResult(source, sourceFormatProfile, hostId, captureRunId, originPath, seed) {
1796
1834
  const serializedSeed = JSON.stringify(seed.records);