( msg: AttachmentMessage, breakdown: MessageBreakdown, )
| 838 | } |
| 839 | |
| 840 | function processAttachment( |
| 841 | msg: AttachmentMessage, |
| 842 | breakdown: MessageBreakdown, |
| 843 | ): void { |
| 844 | const contentStr = jsonStringify(msg.attachment) |
| 845 | const tokens = roughTokenCountEstimation(contentStr) |
| 846 | breakdown.attachmentTokens += tokens |
| 847 | const attachType = msg.attachment.type || 'unknown' |
| 848 | breakdown.attachmentsByType.set( |
| 849 | attachType, |
| 850 | (breakdown.attachmentsByType.get(attachType) || 0) + tokens, |
| 851 | ) |
| 852 | } |
| 853 | |
| 854 | async function approximateMessageTokens( |
| 855 | messages: Message[], |
no test coverage detected