MCPcopy Create free account
hub / github.com/WJX20/claude-code / buildImageContentBlocks

Function buildImageContentBlocks

src/utils/attachments.ts:1104–1130  ·  view source on GitHub ↗
(
  pastedContents: Record<number, PastedContent> | undefined,
)

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 1

Tested by

no test coverage detected