function stringifyAgentError(_0xe3c033){if(!_0xe3c033)return'';if(typeof _0xe3c033==='string')return _0xe3c033;if(typeof _0xe3c033['message']==='string')return _0xe3c033['message'];try{return JSON['stringify'](_0xe3c033);}catch{return String(_0xe3c033);}}function truncateAgentError(_0x138686,_0x34c20e=0x64){const _0x2d75f0=String(_0x138686||'');if(_0x2d75f0['length']<=_0x34c20e)return _0x2d75f0;return _0x2d75f0['substring'](0x0,_0x34c20e)+'...';}export function isAgentErrorEvent(_0xf3955e){return _0xf3955e?.['type']==='error'||_0xf3955e?.['type']==='turn.failed'||_0xf3955e?.['type']==='result'&&_0xf3955e?.['status']==='error';}export function getAgentErrorMessage(_0x587b1e){return stringifyAgentError(_0x587b1e?.['error']?.['message'])||stringifyAgentError(_0x587b1e?.['message'])||stringifyAgentError(_0x587b1e?.['error'])||'Agent\x20reported\x20an\x20error';}export function classifyAgentErrorAction(_0x3b98d7,_0x171ee9='Agent\x20Error'){const _0x794b4a=String(_0x3b98d7||'');if(/\b(?:401|403|unauthorized|forbidden|authentication|auth method|api key|GEMINI_API_KEY|GOOGLE_GENAI_USE_VERTEXAI|GOOGLE_GENAI_USE_GCA)\b/i['test'](_0x794b4a))return'Authentication\x20Error';if(/\b(?:429|rate limit|resource exhausted)\b/i['test'](_0x794b4a))return'Rate\x20Limit\x20Exceeded';if(/\btimeout\b/i['test'](_0x794b4a))return'Timeout';return _0x171ee9;}export function buildAgentErrorActivity(_0x5559a8,_0x32098f={}){const _0x564269=getAgentErrorMessage(_0x5559a8),_0x1c1c7e=_0x5559a8?.['type']==='turn.failed'||_0x5559a8?.['type']==='result'?'Agent\x20Failed':'Agent\x20Error',_0x4d5f6a=_0x32098f['idSeed']??0x0;return{'icon':'❌','action':classifyAgentErrorAction(_0x564269,_0x1c1c7e),'detail':truncateAgentError(_0x564269,0x64),'status':'error','id':'agent-error-'+(_0x5559a8?.['timestamp']||_0x4d5f6a)+'-'+(_0x5559a8?.['type']||'unknown'),'fullContent':_0x564269,'expandable':!![],'timestamp':_0x5559a8?.['timestamp'],'rawData':{'event':_0x5559a8}};}