(obj: unknown)
| 36 | * Used when serializing tool results to avoid transmitting large image data. |
| 37 | */ |
| 38 | export function stripAvatarFields(obj: unknown): void { |
| 39 | if (!obj || typeof obj !== 'object') return |
| 40 | if (Array.isArray(obj)) { |
| 41 | for (const item of obj) stripAvatarFields(item) |
| 42 | return |
| 43 | } |
| 44 | const record = obj as Record<string, unknown> |
| 45 | for (const key of Object.keys(record)) { |
| 46 | if ((key === 'avatar' || key === 'senderAvatar') && typeof record[key] === 'string') { |
| 47 | if ((record[key] as string).length > 200) { |
| 48 | record[key] = '[stripped]' |
| 49 | } |
| 50 | } else if (typeof record[key] === 'object' && record[key] !== null) { |
| 51 | stripAvatarFields(record[key]) |
| 52 | } |
| 53 | } |
| 54 | } |
no outgoing calls
no test coverage detected