(text: string)
| 120 | * Use Anthropic's API for precise counts when needed. |
| 121 | */ |
| 122 | export function estimateTokens(text: string): number { |
| 123 | if (!text) return 0; |
| 124 | // Conservative estimate: ~3.5 characters per token |
| 125 | // This slightly overestimates which is safer than underestimating |
| 126 | return Math.ceil(text.length / 3.5); |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Message turn structure (matches prompts.ts) |
no outgoing calls
no test coverage detected