| 7 | const MAX_OUTPUT_CHARS = 30000; |
| 8 | |
| 9 | function truncateOutput(output: string): string { |
| 10 | if (output.length <= MAX_OUTPUT_CHARS) return output; |
| 11 | const truncated = output.slice(0, MAX_OUTPUT_CHARS); |
| 12 | return `${truncated}\n\n[OUTPUT TRUNCATED: showing ${MAX_OUTPUT_CHARS.toLocaleString()} of ${output.length.toLocaleString()} characters. Use LIMIT or more specific WHERE clauses to narrow results.]`; |
| 13 | } |
| 14 | |
| 15 | // Use createRequire to load better-sqlite3 from the actual node_modules path |
| 16 | // This bypasses the Braintrust CLI's eval bundling which breaks native modules |