( pastedContents: Record<number, PastedContent> | undefined, )
| 1155 | } |
| 1156 | |
| 1157 | async function buildImageContentBlocks( |
| 1158 | pastedContents: Record<number, PastedContent> | undefined, |
| 1159 | ): Promise<ImageBlockParam[]> { |
| 1160 | if (!pastedContents) { |
| 1161 | return [] |
| 1162 | } |
| 1163 | const imageContents = Object.values(pastedContents).filter(isValidImagePaste) |
| 1164 | if (imageContents.length === 0) { |
| 1165 | return [] |
| 1166 | } |
| 1167 | const results = await Promise.all( |
| 1168 | imageContents.map(async img => { |
| 1169 | const imageBlock: ImageBlockParam = { |
| 1170 | type: 'image', |
| 1171 | source: { |
| 1172 | type: 'base64', |
| 1173 | media_type: (img.mediaType || |
| 1174 | 'image/png') as Base64ImageSource['media_type'], |
| 1175 | data: img.content, |
| 1176 | }, |
| 1177 | } |
| 1178 | const resized = await maybeResizeAndDownsampleImageBlock(imageBlock) |
| 1179 | return resized.block |
| 1180 | }), |
| 1181 | ) |
| 1182 | return results |
| 1183 | } |
| 1184 | |
| 1185 | function getPlanModeAttachmentTurnCount(messages: Message[]): { |
| 1186 | turnCount: number |
no test coverage detected