(output: unknown)
| 181 | } |
| 182 | |
| 183 | export function formatToolOutput(output: unknown): string { |
| 184 | if (!output) return '' |
| 185 | |
| 186 | if (Array.isArray(output)) { |
| 187 | return output |
| 188 | .map((item) => { |
| 189 | if (item.type === 'json') { |
| 190 | // Handle errorMessage in the value object |
| 191 | if ( |
| 192 | item.value && |
| 193 | typeof item.value === 'object' && |
| 194 | 'errorMessage' in item.value |
| 195 | ) { |
| 196 | return String(item.value.errorMessage) |
| 197 | } |
| 198 | return toYaml(item.value) |
| 199 | } |
| 200 | if (item.type === 'text') { |
| 201 | return item.text || '' |
| 202 | } |
| 203 | return String(item) |
| 204 | }) |
| 205 | .join('\n') |
| 206 | } |
| 207 | |
| 208 | if (typeof output === 'string') { |
| 209 | return output |
| 210 | } |
| 211 | |
| 212 | return toYaml(output) |
| 213 | } |
no test coverage detected