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