(content)
| 429 | } |
| 430 | |
| 431 | function flattenBlockText(content) { |
| 432 | if (typeof content === 'string') { |
| 433 | return content |
| 434 | } |
| 435 | if (!Array.isArray(content)) { |
| 436 | return '' |
| 437 | } |
| 438 | return content |
| 439 | .map(block => { |
| 440 | if (typeof block === 'string') { |
| 441 | return block |
| 442 | } |
| 443 | if (block?.type === 'text' && typeof block.text === 'string') { |
| 444 | return block.text |
| 445 | } |
| 446 | return JSON.stringify(block) |
| 447 | }) |
| 448 | .join('\n') |
| 449 | .trim() |
| 450 | } |
| 451 | |
| 452 | function trimContextText(value, max = contextEntryCharLimit) { |
| 453 | const text = String(value || '').trim() |
no outgoing calls
no test coverage detected