(content: MCPToolResult)
| 57 | } |
| 58 | |
| 59 | export function getContentSizeEstimate(content: MCPToolResult): number { |
| 60 | if (!content) return 0 |
| 61 | |
| 62 | if (typeof content === 'string') { |
| 63 | return roughTokenCountEstimation(content) |
| 64 | } |
| 65 | |
| 66 | return content.reduce((total, block) => { |
| 67 | if (isTextBlock(block)) { |
| 68 | return total + roughTokenCountEstimation(block.text) |
| 69 | } else if (isImageBlock(block)) { |
| 70 | // Estimate for image tokens |
| 71 | return total + IMAGE_TOKEN_ESTIMATE |
| 72 | } |
| 73 | return total |
| 74 | }, 0) |
| 75 | } |
| 76 | |
| 77 | function getMaxMcpOutputChars(): number { |
| 78 | return getMaxMcpOutputTokens() * 4 |
no test coverage detected