MCPcopy Create free account
hub / github.com/freecodexyz/free-code / isBase64ImageBlock

Function isBase64ImageBlock

src/utils/imageValidation.ts:40–49  ·  view source on GitHub ↗

* Type guard to check if a block is a base64 image block

(
  block: unknown,
)

Source from the content-addressed store, hash-verified

38 * Type guard to check if a block is a base64 image block
39 */
40function isBase64ImageBlock(
41 block: unknown,
42): block is { type: 'image'; source: { type: 'base64'; data: string } } {
43 if (typeof block !== 'object' || block === null) return false
44 const b = block as Record<string, unknown>
45 if (b.type !== 'image') return false
46 if (typeof b.source !== 'object' || b.source === null) return false
47 const source = b.source as Record<string, unknown>
48 return source.type === 'base64' && typeof source.data === 'string'
49}
50
51/**
52 * Validates that all images in messages are within the API size limit.

Callers 1

validateImagesForAPIFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected