(state: SessionState, messages: WithParts[])
| 74 | } |
| 75 | |
| 76 | export function countTurns(state: SessionState, messages: WithParts[]): number { |
| 77 | let turnCount = 0 |
| 78 | for (const msg of messages) { |
| 79 | if (!isMessageWithInfo(msg)) { |
| 80 | continue |
| 81 | } |
| 82 | if (isMessageCompacted(state, msg)) { |
| 83 | continue |
| 84 | } |
| 85 | const parts = Array.isArray(msg.parts) ? msg.parts : [] |
| 86 | for (const part of parts) { |
| 87 | if (part.type === "step-start") { |
| 88 | turnCount++ |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | return turnCount |
| 93 | } |
| 94 | |
| 95 | export function loadPruneMap(obj?: Record<string, number>): Map<string, number> { |
| 96 | if (!obj || typeof obj !== "object") { |
no test coverage detected