MCPcopy
hub / github.com/7836246/cursor2api / estimateCursorReqTokens

Function estimateCursorReqTokens

src/handler.ts:103–111  ·  view source on GitHub ↗
(cursorReq: CursorChatRequest)

Source from the content-addressed store, hash-verified

101 * 对实际发往 Cursor 的完整消息内容做 token 估算(用于与 Cursor 返回值对比)
102 */
103export 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
113export function estimateInputTokens(body: AnthropicRequest): number {
114 let total = 0;

Callers 3

handleDirectTextStreamFunction · 0.85
handleStreamFunction · 0.85
handleNonStreamFunction · 0.85

Calls 1

estimateTokensFunction · 0.85

Tested by

no test coverage detected