diff --git a/src/core/agent/AntigravityProvider.ts b/src/core/agent/AntigravityProvider.ts index e641442..3c7ddce 100644 --- a/src/core/agent/AntigravityProvider.ts +++ b/src/core/agent/AntigravityProvider.ts @@ -117,8 +117,11 @@ export class AntigravityProvider implements AgentProvider { child.kill(); }, 5 * 60 * 1000); + const stdoutDecoder = new TextDecoder('utf-8'); + const stderrDecoder = new TextDecoder('utf-8'); + child.stdout!.on('data', (chunk: Buffer) => { - const text = chunk.toString(); + const text = stdoutDecoder.decode(chunk, { stream: true }); stdoutFull += text; stdoutBuffer += text; const lines = stdoutBuffer.split(/\r?\n/); @@ -129,7 +132,7 @@ export class AntigravityProvider implements AgentProvider { } }); child.stderr!.on('data', (chunk: Buffer) => { - const text = chunk.toString(); + const text = stderrDecoder.decode(chunk, { stream: true }); stderrFull += text; stderrBuffer += text; }); @@ -138,6 +141,8 @@ export class AntigravityProvider implements AgentProvider { done = true; }); child.on('close', (code) => { + stdoutFull += stdoutDecoder.decode(); + stderrFull += stderrDecoder.decode(); exitCode = code; window.clearTimeout(timeout); if (code && code !== 0) { diff --git a/src/core/cli/ExternalCliRunner.ts b/src/core/cli/ExternalCliRunner.ts index 4c8b595..fbab03f 100644 --- a/src/core/cli/ExternalCliRunner.ts +++ b/src/core/cli/ExternalCliRunner.ts @@ -151,22 +151,27 @@ function runProcess(command: string, args: string[], env: NodeJS.ProcessEnv, cwd windowsHide: false, }); + const stdoutDecoder = new TextDecoder('utf-8'); + const stderrDecoder = new TextDecoder('utf-8'); + const timeout = globalThis.setTimeout(() => { child.kill('SIGTERM'); reject(new Error(`${path.basename(command)} timed out after ${Math.round(timeoutMs / 1000)} seconds`)); }, timeoutMs); child.stdout?.on('data', (chunk: Buffer) => { - stdout += chunk.toString(); + stdout += stdoutDecoder.decode(chunk, { stream: true }); }); child.stderr?.on('data', (chunk: Buffer) => { - stderr += chunk.toString(); + stderr += stderrDecoder.decode(chunk, { stream: true }); }); child.on('error', (error) => { globalThis.clearTimeout(timeout); reject(error); }); child.on('close', (code) => { + stdout += stdoutDecoder.decode(); + stderr += stderrDecoder.decode(); globalThis.clearTimeout(timeout); if (code && code !== 0) { reject(new Error(`${path.basename(command)} exited with code ${code}\n${stderr || stdout}`.trim()));