function stringifyAgentError(_0x5bb4a8){if(!_0x5bb4a8)return'';if(typeof _0x5bb4a8==='string')return _0x5bb4a8;if(typeof _0x5bb4a8['message']==='string')return _0x5bb4a8['message'];try{return JSON['stringify'](_0x5bb4a8);}catch{return String(_0x5bb4a8);}}function truncateAgentError(_0x2779a9,_0x453717=0x64){const _0x3db5cc=String(_0x2779a9||'');if(_0x3db5cc['length']<=_0x453717)return _0x3db5cc;return _0x3db5cc['substring'](0x0,_0x453717)+'...';}export function isAgentErrorEvent(_0x96ab3d){return _0x96ab3d?.['type']==='error'||_0x96ab3d?.['type']==='turn.failed'||_0x96ab3d?.['type']==='result'&&_0x96ab3d?.['status']==='error';}export function getAgentErrorMessage(_0x1fd92f){return stringifyAgentError(_0x1fd92f?.['error']?.['message'])||stringifyAgentError(_0x1fd92f?.['message'])||stringifyAgentError(_0x1fd92f?.['error'])||'Agent\x20reported\x20an\x20error';}export function classifyAgentErrorAction(_0x1ac592,_0x1200a7='Agent\x20Error'){const _0x57a7ed=String(_0x1ac592||'');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'](_0x57a7ed))return'Authentication\x20Error';if(/\b(?:429|rate limit|resource exhausted)\b/i['test'](_0x57a7ed))return'Rate\x20Limit\x20Exceeded';if(/\btimeout\b/i['test'](_0x57a7ed))return'Timeout';return _0x1200a7;}export function buildAgentErrorActivity(_0x23764a,_0x5e6f59={}){const _0xff56dd=getAgentErrorMessage(_0x23764a),_0x162a09=_0x23764a?.['type']==='turn.failed'||_0x23764a?.['type']==='result'?'Agent\x20Failed':'Agent\x20Error',_0x44b4ce=_0x5e6f59['idSeed']??0x0;return{'icon':'❌','action':classifyAgentErrorAction(_0xff56dd,_0x162a09),'detail':truncateAgentError(_0xff56dd,0x64),'status':'error','id':'agent-error-'+(_0x23764a?.['timestamp']||_0x44b4ce)+'-'+(_0x23764a?.['type']||'unknown'),'fullContent':_0xff56dd,'expandable':!![],'timestamp':_0x23764a?.['timestamp'],'rawData':{'event':_0x23764a}};}