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