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 c2a17ae257
commit 63a6211fe0
2 changed files with 45 additions and 12 deletions

View File

@@ -532,10 +532,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;
@@ -676,6 +674,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;