(jsonlContent: string)
| 62 | } |
| 63 | |
| 64 | export function parseTranscript(jsonlContent: string): LogEntry[] { |
| 65 | const entries: LogEntry[] = []; |
| 66 | const lines = jsonlContent.split('\n').filter((l) => l.trim()); |
| 67 | |
| 68 | for (const line of lines) { |
| 69 | let obj: TranscriptLine; |
| 70 | try { |
| 71 | obj = JSON.parse(line); |
| 72 | } catch { |
| 73 | continue; |
| 74 | } |
| 75 | |
| 76 | const time = formatTime(obj.timestamp); |
| 77 | |
| 78 | // System messages |
| 79 | if (obj.type === 'system') { |
| 80 | if (obj.subtype === 'init') { |
| 81 | entries.push({ |
| 82 | time, |
| 83 | type: 'system', |
| 84 | content: `Session initialized: ${obj.session_id || ''}`, |
| 85 | }); |
| 86 | } else if (obj.subtype === 'task_started') { |
| 87 | entries.push({ time, type: 'system', content: `Task started` }); |
| 88 | } else if (obj.subtype === 'task_notification') { |
| 89 | const tn = obj as unknown as { |
| 90 | task_id: string; |
| 91 | status: string; |
| 92 | summary: string; |
| 93 | }; |
| 94 | entries.push({ |
| 95 | time, |
| 96 | type: 'system', |
| 97 | content: `Task ${tn.task_id}: ${tn.status} - ${tn.summary}`, |
| 98 | }); |
| 99 | } else { |
| 100 | entries.push({ |
| 101 | time, |
| 102 | type: 'system', |
| 103 | content: `${obj.subtype || 'system event'}`, |
| 104 | }); |
| 105 | } |
| 106 | continue; |
| 107 | } |
| 108 | |
| 109 | // Queue operations |
| 110 | if (obj.type === 'queue-operation') { |
| 111 | continue; // Skip internal queue ops |
| 112 | } |
| 113 | |
| 114 | // Rate limit events |
| 115 | if (obj.type === 'rate_limit_event') { |
| 116 | entries.push({ |
| 117 | time, |
| 118 | type: 'system', |
| 119 | content: 'Rate limit hit, waiting...', |
| 120 | }); |
| 121 | continue; |
no test coverage detected