add suppressConsoleOutput

This commit is contained in:
Cynthia Long
2026-03-16 18:22:10 +00:00
parent fd62938945
commit db9eef50ef
4 changed files with 9 additions and 2 deletions
+1
View File
@@ -271,6 +271,7 @@ export async function main() {
const isDebugMode = cliConfig.isDebugMode(argv);
const consolePatcher = new ConsolePatcher({
stderr: true,
suppressConsoleOutput: true,
debugMode: isDebugMode,
onNewMessage: (msg) => {
coreEvents.emitConsoleLog(msg.type, msg.content);
+2 -2
View File
@@ -513,7 +513,7 @@ describe('runNonInteractive', () => {
.mockReturnValueOnce(createStreamFromEvents(finalResponse));
await runNonInteractive({
config: mockConfig,
config: { ...mockConfig, getDebugMode: () => true } as Config,
settings: mockSettings,
input: 'Trigger tool error',
prompt_id: 'prompt-id-3',
@@ -608,7 +608,7 @@ describe('runNonInteractive', () => {
.mockReturnValueOnce(createStreamFromEvents(finalResponse));
await runNonInteractive({
config: mockConfig,
config: { ...mockConfig, getDebugMode: () => true } as Config,
settings: mockSettings,
input: 'Trigger tool not found',
prompt_id: 'prompt-id-5',
+1
View File
@@ -65,6 +65,7 @@ export async function runNonInteractive({
return promptIdContext.run(prompt_id, async () => {
const consolePatcher = new ConsolePatcher({
stderr: true,
suppressConsoleOutput: true,
debugMode: config.getDebugMode(),
onNewMessage: (msg) => {
coreEvents.emitConsoleLog(msg.type, msg.content);
@@ -13,6 +13,7 @@ interface ConsolePatcherParams {
onNewMessage?: (message: Omit<ConsoleMessageItem, 'id'>) => void;
debugMode: boolean;
stderr?: boolean;
suppressConsoleOutput?: boolean;
}
export class ConsolePatcher {
@@ -49,6 +50,10 @@ export class ConsolePatcher {
private patchConsoleMethod =
(type: 'log' | 'warn' | 'error' | 'debug' | 'info') =>
(...args: unknown[]) => {
if (this.params.suppressConsoleOutput && !this.params.debugMode) {
return;
}
if (this.params.stderr) {
if (type !== 'debug' || this.params.debugMode) {
this.originalConsoleError(this.formatArgs(args));