mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-27 21:44:25 -07:00
fix(cli): Add delimiter before printing tool response in non-interactive mode (#11351)
This commit is contained in:
@@ -40,6 +40,7 @@ import {
|
||||
handleCancellationError,
|
||||
handleMaxTurnsExceededError,
|
||||
} from './utils/errors.js';
|
||||
import { TextOutput } from './ui/utils/textOutput.js';
|
||||
|
||||
export async function runNonInteractive(
|
||||
config: Config,
|
||||
@@ -52,6 +53,7 @@ export async function runNonInteractive(
|
||||
stderr: true,
|
||||
debugMode: config.getDebugMode(),
|
||||
});
|
||||
const textOutput = new TextOutput();
|
||||
|
||||
const handleUserFeedback = (payload: UserFeedbackPayload) => {
|
||||
const prefix = payload.severity.toUpperCase();
|
||||
@@ -183,7 +185,9 @@ export async function runNonInteractive(
|
||||
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
||||
responseText += event.value;
|
||||
} else {
|
||||
process.stdout.write(event.value);
|
||||
if (event.value) {
|
||||
textOutput.write(event.value);
|
||||
}
|
||||
}
|
||||
} else if (event.type === GeminiEventType.ToolCallRequest) {
|
||||
if (streamFormatter) {
|
||||
@@ -220,6 +224,7 @@ export async function runNonInteractive(
|
||||
}
|
||||
|
||||
if (toolCallRequests.length > 0) {
|
||||
textOutput.ensureTrailingNewline();
|
||||
const toolResponseParts: Part[] = [];
|
||||
const completedToolCalls: CompletedToolCall[] = [];
|
||||
|
||||
@@ -297,9 +302,9 @@ export async function runNonInteractive(
|
||||
} else if (config.getOutputFormat() === OutputFormat.JSON) {
|
||||
const formatter = new JsonFormatter();
|
||||
const stats = uiTelemetryService.getMetrics();
|
||||
process.stdout.write(formatter.format(responseText, stats));
|
||||
textOutput.write(formatter.format(responseText, stats));
|
||||
} else {
|
||||
process.stdout.write('\n'); // Ensure a final newline
|
||||
textOutput.ensureTrailingNewline(); // Ensure a final newline
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user