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

Function getLogsWithoutIndex

src/utils/sessionStorage.ts:4971–4999  ·  view source on GitHub ↗

* Gets logs by loading all session files fully, bypassing the session index. * Use this when you need full message data (e.g., for /insights analysis).

(
  projectDir: string,
  limit?: number,
)

Source from the content-addressed store, hash-verified

4969
4970 */
4971async function getLogsWithoutIndex(
4972 projectDir: string,
4973 limit?: number,
4974): Promise<LogOption[]> {
4975 const sessionFilesMap = await getSessionFilesWithMtime(projectDir)
4976 if (sessionFilesMap.size === 0) return []
4977
4978 // If limit specified, only load N most recent files by mtime
4979 let filesToProcess: Array<{ path: string; mtime: number }>
4980 if (limit && sessionFilesMap.size > limit) {
4981 filesToProcess = [...sessionFilesMap.values()]
4982 .sort((a, b) => b.mtime - a.mtime)
4983 .slice(0, limit)
4984 } else {
4985 filesToProcess = [...sessionFilesMap.values()]
4986 }
4987
4988 const logs: LogOption[] = []
4989 for (const fileInfo of filesToProcess) {
4990 try {
4991 const fileLogOptions = await loadAllLogsFromSessionFile(fileInfo.path)
4992 logs.push(...fileLogOptions)
4993 } catch {
4994 logForDebugging(`Failed to load session file: ${fileInfo.path}`)
4995 }
4996 }
4997
4998 return logs
4999}
5000
5001/**
5002 * Reads the first and last ~64KB of a JSONL file and extracts lite metadata.

Callers 1

Calls 3

getSessionFilesWithMtimeFunction · 0.85
logForDebuggingFunction · 0.70

Tested by

no test coverage detected