MCPcopy Create free account
hub / github.com/Noumena-Network/code / enrichLogs

Function enrichLogs

src/utils/sessionStorage.ts:5347–5375  ·  view source on GitHub ↗
(
  allLogs: LogOption[],
  startIndex: number,
  count: number,
)

Source from the content-addressed store, hash-verified

5345 * index where scanning stopped (for progressive loading to continue from).
5346 */
5347export async function enrichLogs(
5348 allLogs: LogOption[],
5349 startIndex: number,
5350 count: number,
5351): Promise<{ logs: LogOption[]; nextIndex: number }> {
5352 const result: LogOption[] = []
5353 const readBuf = Buffer.alloc(LITE_READ_BUF_SIZE)
5354 let i = startIndex
5355
5356 while (i < allLogs.length && result.length < count) {
5357 const log = allLogs[i]!
5358 i++
5359
5360 const enriched = await enrichLog(log, readBuf)
5361 if (enriched) {
5362 result.push(enriched)
5363 }
5364 }
5365
5366 const scanned = i - startIndex
5367 const filtered = scanned - result.length
5368 if (filtered > 0) {
5369 logForDebugging(
5370 `/resume: enriched ${scanned} sessions, ${filtered} filtered out, ${result.length} visible (${allLogs.length - i} remaining on disk)`,
5371 )
5372 }
5373
5374 return { logs: result, nextIndex: i }
5375}

Callers 5

loadMessageLogsFunction · 0.85
ResumeConversationFunction · 0.85

Calls 2

enrichLogFunction · 0.85
logForDebuggingFunction · 0.70

Tested by

no test coverage detected