mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-02 07:54:48 -07:00
fix: report AgentExecutionBlocked in non-interactive programmatic modes (#26262)
This commit is contained in:
@@ -331,4 +331,19 @@ describe('JsonFormatter', () => {
|
||||
expect(parsed.error.message).toBe('Error\x07 with\x08 control\x0B chars');
|
||||
expect(() => JSON.parse(formatted)).not.toThrow();
|
||||
});
|
||||
|
||||
it('should format warnings as JSON', () => {
|
||||
const formatter = new JsonFormatter();
|
||||
const warnings = ['Warning 1', '\x1B[33mWarning 2 with ANSI\x1B[0m'];
|
||||
const formatted = formatter.format(
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
warnings,
|
||||
);
|
||||
const parsed = JSON.parse(formatted);
|
||||
|
||||
expect(parsed.warnings).toEqual(['Warning 1', 'Warning 2 with ANSI']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,6 +15,7 @@ export class JsonFormatter {
|
||||
response?: string,
|
||||
stats?: SessionMetrics,
|
||||
error?: JsonError,
|
||||
warnings?: string[],
|
||||
): string {
|
||||
const output: JsonOutput = {};
|
||||
|
||||
@@ -34,6 +35,10 @@ export class JsonFormatter {
|
||||
output.error = error;
|
||||
}
|
||||
|
||||
if (warnings && warnings.length > 0) {
|
||||
output.warnings = warnings.map((w) => stripAnsi(w));
|
||||
}
|
||||
|
||||
return JSON.stringify(output, null, 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ export interface JsonOutput {
|
||||
response?: string;
|
||||
stats?: SessionMetrics;
|
||||
error?: JsonError;
|
||||
warnings?: string[];
|
||||
}
|
||||
|
||||
// Streaming JSON event types
|
||||
|
||||
Reference in New Issue
Block a user