(error: any)
| 61 | |
| 62 | // Helper function to extract error messages properly |
| 63 | function extractErrorMessage(error: any): string { |
| 64 | if (typeof error === 'string') return error; |
| 65 | if (error instanceof Error) return error.message; |
| 66 | if (error?.message) return error.message; |
| 67 | if (error?.toString && typeof error.toString === 'function') return error.toString(); |
| 68 | return String(error); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Execute JavaScript handler for processing agent responses |