MCPcopy Create free account
hub / github.com/dwgx/WindsurfAPI / normalizeBinary

Function normalizeBinary

src/cache.js:84–98  ·  view source on GitHub ↗
(messages)

Source from the content-addressed store, hash-verified

82}
83
84function normalizeBinary(messages) {
85 if (!Array.isArray(messages)) return messages;
86 return messages.map(m => {
87 if (!Array.isArray(m.content)) return m;
88 return { ...m, content: m.content.map(p => {
89 if (p.type === 'image_url' && typeof p.image_url?.url === 'string' && p.image_url.url.startsWith('data:'))
90 return { ...p, image_url: { ...p.image_url, url: normalizeDataUrl(p.image_url.url) } };
91 if (p.type === 'image' && p.source?.type === 'base64')
92 return { ...p, source: { ...p.source, data: digestBase64Data(p.source.data, p.source.media_type) } };
93 if ((p.type === 'file' || p.type === 'input_file') && typeof p.file?.file_data === 'string' && p.file.file_data.startsWith('data:'))
94 return { ...p, file: { ...p.file, file_data: normalizeDataUrl(p.file.file_data) } };
95 return p;
96 })};
97 });
98}
99
100function normalize(body) {
101 return {

Callers 1

normalizeFunction · 0.85

Calls 2

normalizeDataUrlFunction · 0.85
digestBase64DataFunction · 0.85

Tested by

no test coverage detected