Skip to content

Commit 3a9ec67

Browse files
committed
fix(file): align archive ops with v5 output surface and zip mime
- Drop the single 'file' output reintroduced for compress/decompress; v5 intentionally exposes only 'files' (plus id/name/size/url scalars), so compress/decompress reuse the existing surface with no new block output - Add zip/gz to EXTENSION_TO_MIME (previously only in the reverse map), so archive extensions resolve to a real mime instead of octet-stream - Update File v5 block test for the two new operations
1 parent 3dfc9cc commit 3a9ec67

6 files changed

Lines changed: 11 additions & 11 deletions

File tree

apps/sim/app/api/tools/file/manage/route.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,6 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
646646
name: compressedFile.name,
647647
size: compressedFile.size,
648648
url: compressedFile.url,
649-
file: compressedFile,
650649
files: [compressedFile],
651650
},
652651
})
@@ -783,7 +782,6 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
783782
return NextResponse.json({
784783
success: true,
785784
data: {
786-
file: extractedFiles[0],
787785
files: extractedFiles,
788786
},
789787
})

apps/sim/blocks/blocks.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ describe.concurrent('Blocks Module', () => {
172172
'file_fetch',
173173
'file_write',
174174
'file_append',
175+
'file_compress',
176+
'file_decompress',
175177
])
178+
expect(block?.tools.config?.tool({ operation: 'file_compress' })).toBe('file_compress')
179+
expect(block?.tools.config?.tool({ operation: 'file_decompress' })).toBe('file_decompress')
176180
expect(block?.subBlocks.find((subBlock) => subBlock.id === 'readFile')?.multiple).toBe(true)
177181
expect(block?.tools.config?.tool({ operation: 'file_read' })).toBe('file_read')
178182
expect(block?.tools.config?.tool({ operation: 'file_get_content' })).toBe('file_get_content')

apps/sim/blocks/blocks/file.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,11 +1222,7 @@ export const FileV5Block: BlockConfig<FileParserV3Output> = {
12221222
files: {
12231223
type: 'file[]',
12241224
description:
1225-
'Workspace file objects (read), fetched file objects (fetch), or the compressed archive (compress)',
1226-
},
1227-
file: {
1228-
type: 'file',
1229-
description: 'Compressed archive file object (compress)',
1225+
'Workspace file objects (read), fetched file objects (fetch), the compressed archive (compress), or extracted files (decompress)',
12301226
},
12311227
contents: {
12321228
type: 'array',

apps/sim/lib/uploads/utils/file-utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ const EXTENSION_TO_MIME: Record<string, string> = {
241241
yml: 'application/x-yaml',
242242
rtf: 'application/rtf',
243243

244+
// Archives
245+
zip: 'application/zip',
246+
gz: 'application/gzip',
247+
244248
// Code / plain-text source
245249
py: 'text/x-python',
246250
js: 'text/javascript',

apps/sim/tools/file/compress.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ describe('fileDecompressTool', () => {
9898
]
9999

100100
const result = await fileDecompressTool.transformResponse?.(
101-
Response.json({ success: true, data: { file: extracted[0], files: extracted } })
101+
Response.json({ success: true, data: { files: extracted } })
102102
)
103103

104104
expect(result).toMatchObject({
105105
success: true,
106-
output: { file: extracted[0], files: extracted },
106+
output: { files: extracted },
107107
})
108108
})
109109

apps/sim/tools/file/compress.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export const fileCompressTool: ToolConfig<FileCompressParams, ToolResponse> = {
6363
name: { type: 'string', description: 'Compressed archive file name' },
6464
size: { type: 'number', description: 'Compressed archive size in bytes' },
6565
url: { type: 'string', description: 'URL to access the compressed archive', optional: true },
66-
file: { type: 'file', description: 'Compressed archive file object' },
6766
files: {
6867
type: 'file[]',
6968
description: 'Compressed archive file object, as a single-item array',
@@ -122,6 +121,5 @@ export const fileDecompressTool: ToolConfig<FileDecompressParams, ToolResponse>
122121

123122
outputs: {
124123
files: { type: 'file[]', description: 'Extracted workspace file objects' },
125-
file: { type: 'file', description: 'First extracted workspace file object' },
126124
},
127125
}

0 commit comments

Comments
 (0)