(filePath)
| 32 | } |
| 33 | |
| 34 | function fileLooksLikeTranscript(filePath) { |
| 35 | try { |
| 36 | const stat = fs.statSync(filePath); |
| 37 | if (stat.size <= 0) return false; |
| 38 | const readSize = Math.min(stat.size, 64 * 1024); |
| 39 | const fd = fs.openSync(filePath, 'r'); |
| 40 | const buf = Buffer.alloc(readSize); |
| 41 | fs.readSync(fd, buf, 0, readSize, stat.size - readSize); |
| 42 | fs.closeSync(fd); |
| 43 | const lines = buf.toString('utf8').split('\n').filter(Boolean); |
| 44 | for (const line of lines) { |
| 45 | try { |
| 46 | const evt = JSON.parse(line); |
| 47 | if (hasConversationEvent(evt)) return true; |
| 48 | } catch {} |
| 49 | } |
| 50 | } catch {} |
| 51 | return false; |
| 52 | } |
| 53 | |
| 54 | function flattenUserContent(content) { |
| 55 | if (typeof content === 'string') return content; |
no test coverage detected