(cursorReq: CursorChatRequest)
| 101 | * 对实际发往 Cursor 的完整消息内容做 token 估算(用于与 Cursor 返回值对比) |
| 102 | */ |
| 103 | export function estimateCursorReqTokens(cursorReq: CursorChatRequest): number { |
| 104 | let total = 0; |
| 105 | for (const msg of cursorReq.messages) { |
| 106 | for (const part of msg.parts) { |
| 107 | total += estimateTokens(part.text ?? ''); |
| 108 | } |
| 109 | } |
| 110 | return total; |
| 111 | } |
| 112 | |
| 113 | export function estimateInputTokens(body: AnthropicRequest): number { |
| 114 | let total = 0; |
no test coverage detected