From 726584146d53e47d4e10c716d7811aab54bcb569 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 30 Aug 2025 19:17:27 -0500 Subject: [PATCH] save the json to the protobuf --- .../core/src/core/loggingContentGenerator.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/core/src/core/loggingContentGenerator.ts b/packages/core/src/core/loggingContentGenerator.ts index a1fdb897..3c1feb62 100644 --- a/packages/core/src/core/loggingContentGenerator.ts +++ b/packages/core/src/core/loggingContentGenerator.ts @@ -30,6 +30,7 @@ import { import { ContentGenerator } from './contentGenerator.js'; import { toContents } from '../code_assist/converter.js'; import { isStructuredError } from '../utils/quotaErrorDetection.js'; +import { ExecException } from 'child_process'; interface StructuredError { status: number; @@ -118,6 +119,15 @@ export class LoggingContentGenerator implements ContentGenerator { const jsonPayload = JSON.stringify(req, null, 2); fs.writeFileSync(filePath, jsonPayload); this.requestCounter++; + const { exec } = require('child_process'); + exec(`regex --json ${filePath}`, (error: ExecException | null, stdout: string, stderr: string) => { + if (error) { + console.error(`exec error: ${error}`); + return; + } + console.log(`stdout: ${stdout}`); + console.error(`stderr: ${stderr}`); + }); const response = await this.wrapped.generateContent(req, userPromptId); const durationMs = Date.now() - startTime; this._logApiResponse( @@ -147,6 +157,15 @@ export class LoggingContentGenerator implements ContentGenerator { const jsonPayload = JSON.stringify(req, null, 2); fs.writeFileSync(filePath, jsonPayload); this.requestCounter++; + const { exec } = require('child_process'); + exec(`regex --json ${filePath}`, (error: ExecException | null, stdout: string, stderr: string) => { + if (error) { + console.error(`exec error: ${error}`); + return; + } + console.log(`stdout: ${stdout}`); + console.error(`stderr: ${stderr}`); + }); let stream: AsyncGenerator; try { stream = await this.wrapped.generateContentStream(req, userPromptId);