(home: string)
| 234 | } |
| 235 | |
| 236 | async function readSessionIndex(home: string): Promise<Map<string, SessionIndexEntry>> { |
| 237 | const out = new Map<string, SessionIndexEntry>(); |
| 238 | let raw: string; |
| 239 | try { |
| 240 | raw = await readFile(join(home, 'session_index.jsonl'), 'utf8'); |
| 241 | } catch { return out; } |
| 242 | for (const line of raw.split(/\r?\n/)) { |
| 243 | if (!line.trim()) continue; |
| 244 | try { |
| 245 | const entry = JSON.parse(line) as { sessionId?: string; sessionDir?: string; workDir?: string }; |
| 246 | if (typeof entry.sessionId === 'string' && typeof entry.sessionDir === 'string') { |
| 247 | out.set(entry.sessionId, { |
| 248 | sessionDir: entry.sessionDir, |
| 249 | workDir: typeof entry.workDir === 'string' ? entry.workDir : '', |
| 250 | }); |
| 251 | } |
| 252 | } catch { /* skip malformed */ } |
| 253 | } |
| 254 | return out; |
| 255 | } |
| 256 | |
| 257 | async function inventoryAgents(sessionDir: string, state: StateJson, deriveHomedir = false): Promise<AgentInfo[]> { |
| 258 | const result: AgentInfo[] = []; |
no test coverage detected