( pastedContents: Record<number, PastedContent> | undefined, )
| 1101 | } |
| 1102 | |
| 1103 | async function buildImageContentBlocks( |
| 1104 | pastedContents: Record<number, PastedContent> | undefined, |
| 1105 | ): Promise<ImageBlockParam[]> { |
| 1106 | if (!pastedContents) { |
| 1107 | return [] |
| 1108 | } |
| 1109 | const imageContents = Object.values(pastedContents).filter(isValidImagePaste) |
| 1110 | if (imageContents.length === 0) { |
| 1111 | return [] |
| 1112 | } |
| 1113 | const results = await Promise.all( |
| 1114 | imageContents.map(async img => { |
| 1115 | const imageBlock: ImageBlockParam = { |
| 1116 | type: 'image', |
| 1117 | source: { |
| 1118 | type: 'base64', |
| 1119 | media_type: (img.mediaType || |
| 1120 | 'image/png') as Base64ImageSource['media_type'], |
| 1121 | data: img.content, |
| 1122 | }, |
| 1123 | } |
| 1124 | const resized = await maybeResizeAndDownsampleImageBlock(imageBlock) |
| 1125 | return resized.block |
| 1126 | }), |
| 1127 | ) |
| 1128 | return results |
| 1129 | } |
| 1130 | |
| 1131 | function getPlanModeAttachmentTurnCount(messages: Message[]): { |
| 1132 | turnCount: number |
no test coverage detected