MCPcopy Create free account
hub / github.com/Noumena-Network/code / parseFileSpecs

Function parseFileSpecs

src/services/api/filesApi.ts:723–749  ·  view source on GitHub ↗
(fileSpecs: string[])

Source from the content-addressed store, hash-verified

721 * @returns Parsed file attachments
722 */
723export function parseFileSpecs(fileSpecs: string[]): File[] {
724 const files: File[] = []
725
726 // Sandbox-gateway may pass multiple specs as a single space-separated string
727 const expandedSpecs = fileSpecs.flatMap(s => s.split(' ').filter(Boolean))
728
729 for (const spec of expandedSpecs) {
730 const colonIndex = spec.indexOf(':')
731 if (colonIndex === -1) {
732 continue
733 }
734
735 const fileId = spec.substring(0, colonIndex)
736 const relativePath = spec.substring(colonIndex + 1)
737
738 if (!fileId || !relativePath) {
739 logDebugError(
740 `Invalid file spec: ${spec}. Both file_id and path are required`,
741 )
742 continue
743 }
744
745 files.push({ fileId, relativePath })
746 }
747
748 return files
749}

Callers 2

runFunction · 0.85
filesApi.test.tsFile · 0.85

Calls 1

logDebugErrorFunction · 0.85

Tested by

no test coverage detected