| 253 | } |
| 254 | |
| 255 | export function stabilizeStructuredContent(content: unknown): unknown { |
| 256 | if (typeof content === 'string') { |
| 257 | return stabilizeResponseOutput(content); |
| 258 | } |
| 259 | if (Array.isArray(content)) { |
| 260 | return content.map(item => stabilizeStructuredContent(item)); |
| 261 | } |
| 262 | if (typeof content === 'object' && content !== null) { |
| 263 | const result: Record<string, unknown> = {}; |
| 264 | for (const [key, value] of Object.entries(content)) { |
| 265 | if (key === 'snapshotFilePath' && typeof value === 'string') { |
| 266 | result[key] = '<file>'; |
| 267 | } else { |
| 268 | result[key] = stabilizeStructuredContent(value); |
| 269 | } |
| 270 | } |
| 271 | return result; |
| 272 | } |
| 273 | return content; |
| 274 | } |
| 275 | |
| 276 | export function stabilizeResponseOutput(text: unknown) { |
| 277 | if (typeof text !== 'string') { |