(error: any)
| 48 | |
| 49 | // Helper function to extract error messages properly |
| 50 | function extractErrorMessage(error: any): string { |
| 51 | if (typeof error === 'string') return error; |
| 52 | if (error instanceof Error) return error.message; |
| 53 | if (error?.message) return error.message; |
| 54 | if (error?.toString && typeof error.toString === 'function') return error.toString(); |
| 55 | return String(error); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Execute JavaScript handler for processing agent responses |