fix(core): ensure binary shell output files are still written to disk for 20MB files, and wait for stream close

This commit is contained in:
Spencer
2026-04-10 15:47:53 +00:00
parent 1089d9f369
commit 35a6bc245a
2 changed files with 45 additions and 12 deletions
+7 -4
View File
@@ -534,10 +534,8 @@ export class ShellToolInvocation extends BaseToolInvocation<
// We rely on 'file_data' for the clean output stream.
break;
case 'file_data':
if (!isBinaryStream) {
totalBytesWritten += Buffer.byteLength(event.chunk);
outputStream.write(event.chunk);
}
totalBytesWritten += Buffer.byteLength(event.chunk);
outputStream.write(event.chunk);
break;
case 'data':
if (isBinaryStream) break;
@@ -678,6 +676,11 @@ export class ShellToolInvocation extends BaseToolInvocation<
outputStream.end(resolve);
});
// Ensure the stream is fully closed before we proceed
if (!outputStream.closed) {
await new Promise<void>((resolve) => outputStream.on('close', resolve));
}
const backgroundPIDs: number[] = [];
if (os.platform() !== 'win32') {
let tempFileExists = false;