@sleep2agi/agent-network 2.3.0-preview.166 → 2.3.0-preview.168

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- const a0_0x550e5e=a0_0x454b;(function(_0x5d3164,_0x248582){const _0x3f1474=a0_0x454b,_0x4354c7=_0x5d3164();while(!![]){try{const _0x23dfc8=-parseInt(_0x3f1474(0xcc))/0x1*(-parseInt(_0x3f1474(0xc3))/0x2)+-parseInt(_0x3f1474(0x96))/0x3+-parseInt(_0x3f1474(0x82))/0x4*(parseInt(_0x3f1474(0x74))/0x5)+-parseInt(_0x3f1474(0xae))/0x6+parseInt(_0x3f1474(0xee))/0x7*(parseInt(_0x3f1474(0xa2))/0x8)+parseInt(_0x3f1474(0xcf))/0x9*(-parseInt(_0x3f1474(0xa8))/0xa)+parseInt(_0x3f1474(0xb6))/0xb*(parseInt(_0x3f1474(0xc8))/0xc);if(_0x23dfc8===_0x248582)break;else _0x4354c7['push'](_0x4354c7['shift']());}catch(_0x4692ba){_0x4354c7['push'](_0x4354c7['shift']());}}}(a0_0x5bad,0x8120f));function a0_0x454b(_0x2bc4d,_0x28d04b){_0x2bc4d=_0x2bc4d-0x6e;const _0x5badd4=a0_0x5bad();let _0x454b5f=_0x5badd4[_0x2bc4d];return _0x454b5f;}import{EventEmitter as a0_0x4da2cc}from'events';import{hostname as a0_0xeea49b}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xd9073e,_0x356d19)=>(_0xd9073e??_0x356d19)[a0_0x550e5e(0xeb)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x550e5e(0xc0)](0x0,0xf0);function N(_0x46f4ba){const _0x21280f=a0_0x550e5e;return(_0x46f4ba instanceof Error?_0x46f4ba[_0x21280f(0xea)]:String(_0x46f4ba??_0x21280f(0x7c)))[_0x21280f(0xeb)](K,_0x21280f(0xbf))[_0x21280f(0xeb)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x21280f(0xc0)](0x0,0xf0);}function O(_0xb049e9,_0x2f9c94=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x38c803=a0_0x550e5e;if(_0x2f9c94)return JSON[_0x38c803(0xb9)](_0xb049e9);let _0xaf8946=L(_0xb049e9[_0x38c803(0x70)],'<missing>'),_0x89adbf=L(_0xb049e9[_0x38c803(0xc2)],_0x38c803(0x88)),_0x32e7bb=_0xb049e9[_0x38c803(0xe1)]?_0x38c803(0xe9)+_0xb049e9[_0x38c803(0xe1)]+':'+(_0xb049e9[_0x38c803(0xe3)]??''):'';return _0x38c803(0xcb)+_0xb049e9[_0x38c803(0xb8)]+_0x38c803(0xd3)+L(_0xb049e9[_0x38c803(0xb5)],_0x38c803(0xa3))+_0x38c803(0x84)+L(_0xb049e9['to_alias'],_0x38c803(0xa3))+'\x20task_id='+_0x89adbf+_0x38c803(0x98)+_0xaf8946+'\x20network_id='+L(_0xb049e9['network_id'],_0x38c803(0xa3))+_0x38c803(0x86)+_0xb049e9['transport']+'\x20duration_ms='+_0xb049e9[_0x38c803(0xc4)]+_0x38c803(0x8d)+_0xb049e9['lifecycle_tracking']+_0x32e7bb;}function U(_0x503960){const _0x4dace1=a0_0x550e5e;return{'event':{'sending':_0x4dace1(0x8f),'delivered':_0x4dace1(0xdc),'failed':_0x4dace1(0xe4),'acked':_0x4dace1(0x6e),'started':_0x4dace1(0x97),'replied':'task.replied','expired':_0x4dace1(0xc7)}[_0x503960[_0x4dace1(0xb8)]],..._0x503960};}function j(_0xd3cc25){const _0x27c330=a0_0x550e5e;let _0x3716be=_0xd3cc25?.[_0x27c330(0xc2)]||_0xd3cc25?.[_0x27c330(0xd0)]||_0xd3cc25?.['id'];if(_0x3716be)return String(_0x3716be);let _0x4e816b=_0xd3cc25?.['content']?.[0x0]?.[_0x27c330(0xad)];if(typeof _0x4e816b!==_0x27c330(0xd4))return null;try{let _0x38bf7f=JSON[_0x27c330(0xac)](_0x4e816b);return _0x38bf7f?.[_0x27c330(0xc2)]||_0x38bf7f?.['message_id']||_0x38bf7f?.['id']||null;}catch{return null;}}async function X(_0xbaac3a,_0x49f54d){const _0x5cee60=a0_0x550e5e;let _0x12d832=_0x49f54d[_0x5cee60(0x94)]??Date['now'],_0x5b8476=_0x12d832(),_0x2303ae=(_0x46dd14,_0x3bbc57,_0x41be2e,_0x361df9)=>{const _0x34e931=_0x5cee60;_0x49f54d[_0x34e931(0x8c)](O(U({'from_alias':_0xbaac3a[_0x34e931(0x80)],'to_alias':_0xbaac3a[_0x34e931(0xc9)],'task_id':_0x3bbc57,'parent_task_id':_0xbaac3a[_0x34e931(0x7f)],'network_id':_0xbaac3a[_0x34e931(0x76)],'transport':_0xbaac3a[_0x34e931(0x79)],'status':_0x46dd14,'duration_ms':_0x12d832()-_0x5b8476,'lifecycle_tracking':_0xbaac3a[_0x34e931(0x83)],..._0x41be2e!==void 0x0?{'error_code':_0x361df9||_0x34e931(0xaa),'error_message':N(_0x41be2e)}:{}})));};_0x2303ae(_0x5cee60(0x9b),null);try{let _0xc6a566=await _0x49f54d[_0x5cee60(0x71)](),_0x552c89=j(_0xc6a566);if(_0x552c89)_0x2303ae(_0x5cee60(0x9f),_0x552c89);else{if(_0xc6a566?.['ok']===!0x1||_0xc6a566?.['error'])_0x2303ae('failed',_0x552c89,_0xc6a566?.[_0x5cee60(0xd8)]||_0x5cee60(0xb1),'send_rejected');else _0x2303ae(_0x5cee60(0xe0),null,_0x5cee60(0xa4),_0x5cee60(0x93));}return _0xc6a566;}catch(_0x4342e8){throw _0x2303ae(_0x5cee60(0xe0),null,_0x4342e8,_0x5cee60(0xaa)),_0x4342e8;}}async function Y(_0x402f9e,_0x5c12fd){const _0x85688c=a0_0x550e5e;return X({'fromAlias':_0x402f9e[_0x85688c(0x80)],'toAlias':_0x402f9e[_0x85688c(0x7d)],'parentTaskId':_0x402f9e[_0x85688c(0x7f)]||null,'networkId':_0x402f9e[_0x85688c(0x76)]||null,'transport':_0x85688c(0xd7),'lifecycleTracking':_0x85688c(0xa5)},_0x5c12fd);}class $ extends a0_0x4da2cc{['url'];[a0_0x550e5e(0x7d)];['token'];['agent'];[a0_0x550e5e(0x99)];[a0_0x550e5e(0xa0)];[a0_0x550e5e(0xd2)];[a0_0x550e5e(0x9d)];[a0_0x550e5e(0xce)];[a0_0x550e5e(0xd1)]=!0x1;constructor(_0x223f70){const _0x55d00a=a0_0x550e5e;super();if(this[_0x55d00a(0x92)]=_0x223f70[_0x55d00a(0x92)][_0x55d00a(0xeb)](/\/$/,''),this['alias']=_0x223f70[_0x55d00a(0x7d)],this[_0x55d00a(0xdb)]=_0x223f70[_0x55d00a(0xdb)],this[_0x55d00a(0x7a)]=_0x223f70[_0x55d00a(0x7a)]||_0x55d00a(0x91),this[_0x55d00a(0x99)]=_0x55d00a(0xc1)+_0x223f70[_0x55d00a(0x7d)]+'-'+Date[_0x55d00a(0x94)]()[_0x55d00a(0xdd)](0x24),this[_0x55d00a(0xa0)]=_0x223f70[_0x55d00a(0xa0)]??0x2bf20,this[_0x55d00a(0xd2)]=_0x223f70['reconnectDelay']??0xbb8,_0x223f70[_0x55d00a(0x72)]!==!0x1)this[_0x55d00a(0x89)]();}[a0_0x550e5e(0x8c)](_0x413b6b){const _0x568a2a=a0_0x550e5e;console[_0x568a2a(0x8c)]('['+new Date()[_0x568a2a(0xe6)]()[_0x568a2a(0xc0)](0x0,0x8)+_0x568a2a(0x73)+this[_0x568a2a(0x7d)]+']\x20'+_0x413b6b);}async[a0_0x550e5e(0xbe)](_0x5ac407,_0x315820){const _0x307eea=a0_0x550e5e;let _0x168ee8={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this[_0x307eea(0xdb)])_0x168ee8[_0x307eea(0x75)]=_0x307eea(0xb3)+this[_0x307eea(0xdb)];let _0xc85a33=await(await fetch(this[_0x307eea(0x92)]+'/mcp',{'method':'POST','headers':_0x168ee8,'body':JSON[_0x307eea(0xb9)]({'jsonrpc':_0x307eea(0xbb),'id':Date[_0x307eea(0x94)](),'method':_0x307eea(0x7b),'params':{'name':_0x5ac407,'arguments':_0x315820}})}))[_0x307eea(0xad)](),_0x160ca6=_0xc85a33['match'](/data: (.+)/),_0x1dc06a=_0x160ca6?JSON[_0x307eea(0xac)](_0x160ca6[0x1]):JSON[_0x307eea(0xac)](_0xc85a33),_0xdc0f8c=_0x1dc06a?.[_0x307eea(0xcd)]?.['content']?.[0x0]?.[_0x307eea(0xad)];return _0xdc0f8c?JSON['parse'](_0xdc0f8c):_0x1dc06a;}async[a0_0x550e5e(0x89)](){const _0x597786=a0_0x550e5e;if(this[_0x597786(0xd1)])return;this['running']=!0x0,await this[_0x597786(0xb8)](_0x597786(0x9e)),this[_0x597786(0x8c)](_0x597786(0xc5)),this[_0x597786(0x9d)]=setInterval(()=>{const _0x242951=_0x597786;this[_0x242951(0xb8)](_0x242951(0x9e))['catch'](_0x50ebc6=>this[_0x242951(0x8c)]('heartbeat\x20failed:\x20'+_0x50ebc6[_0x242951(0xea)]));},this[_0x597786(0xa0)]),this[_0x597786(0xd6)]();}async[a0_0x550e5e(0xc6)](){const _0x5d6fbd=a0_0x550e5e;if(this[_0x5d6fbd(0xd1)]=!0x1,this['sseAbort']?.['abort'](),this[_0x5d6fbd(0x9d)])clearInterval(this['heartbeatTimer']);await this[_0x5d6fbd(0xb8)](_0x5d6fbd(0xbc))[_0x5d6fbd(0x81)](()=>{}),this['log']('disconnected');}async[a0_0x550e5e(0x71)](_0x3860a4,_0x31e0a8,_0x2f7e94=a0_0x550e5e(0x90)){const _0x44634e=a0_0x550e5e;return Y({'alias':_0x3860a4,'fromAlias':this['alias']},{'log':_0x67e2e4=>console[_0x44634e(0x8c)](_0x67e2e4),'send':()=>this[_0x44634e(0xbe)]('send_task',{'alias':_0x3860a4,'task':_0x31e0a8,'priority':_0x2f7e94,'from_session':this['alias']})});}async[a0_0x550e5e(0xea)](_0x434d91,_0x2f1b56){const _0x2155b7=a0_0x550e5e;return this['call']('send_message',{'alias':_0x434d91,'message':_0x2f1b56,'from_session':this[_0x2155b7(0x7d)]});}async[a0_0x550e5e(0x9a)](_0x147d74,_0x451bea,_0x12c0c5=a0_0x550e5e(0xb2)){const _0x577287=a0_0x550e5e;return this['call'](_0x577287(0xde),{'in_reply_to':_0x147d74,'text':_0x451bea,'status':_0x12c0c5});}async[a0_0x550e5e(0xb8)](_0x2060d4,_0x18096b){const _0x31143b=a0_0x550e5e;return this[_0x31143b(0xbe)](_0x31143b(0xbd),{'resume_id':this['resumeId'],'alias':this[_0x31143b(0x7d)],'status':_0x2060d4,'server':a0_0xeea49b(),'hostname':a0_0xeea49b(),'agent':this[_0x31143b(0x7a)],'project_dir':process[_0x31143b(0xa9)](),..._0x18096b});}async['getAllStatus'](){const _0x1e7bf8=a0_0x550e5e;return this[_0x1e7bf8(0xbe)](_0x1e7bf8(0xa6),{});}async['broadcast'](_0x394916,_0x11212a){const _0x31df29=a0_0x550e5e;return this[_0x31df29(0xbe)](_0x31df29(0xab),{'message':_0x394916,'filter_server':_0x11212a?.[_0x31df29(0x85)],'filter_status':_0x11212a?.[_0x31df29(0xb8)]});}async[a0_0x550e5e(0xd6)](){const _0x4c37f6=a0_0x550e5e;let _0x4c3cd2=encodeURIComponent(this[_0x4c37f6(0x7d)]),_0x2aba8e=this[_0x4c37f6(0x92)]+_0x4c37f6(0xa7)+_0x4c3cd2,_0x4d40c6=this[_0x4c37f6(0xd2)];while(this[_0x4c37f6(0xd1)]){try{this['sseAbort']=new AbortController();let _0x475615={'Accept':'text/event-stream'};if(this['token'])_0x475615[_0x4c37f6(0x75)]=_0x4c37f6(0xb3)+this[_0x4c37f6(0xdb)];let _0x2519f6=await fetch(_0x2aba8e,{'headers':_0x475615,'signal':this[_0x4c37f6(0xce)][_0x4c37f6(0xb4)]});if(!_0x2519f6['ok']||!_0x2519f6['body']){this['log'](_0x4c37f6(0x7e)+_0x2519f6[_0x4c37f6(0xb8)]),await this[_0x4c37f6(0xd9)](_0x4d40c6),_0x4d40c6=Math[_0x4c37f6(0xdf)](_0x4d40c6*1.5,0xea60);continue;}_0x4d40c6=this[_0x4c37f6(0xd2)];let _0x5cef41=_0x2519f6[_0x4c37f6(0xa1)]['getReader'](),_0x5877df=new TextDecoder(),_0x5754c4='';while(this['running']){let {done:_0x236d6a,value:_0x37fb7c}=await _0x5cef41[_0x4c37f6(0xda)]();if(_0x236d6a)break;_0x5754c4+=_0x5877df['decode'](_0x37fb7c,{'stream':!0x0});let _0x15f31c=_0x5754c4[_0x4c37f6(0xe5)]('\x0a');_0x5754c4=_0x15f31c[_0x4c37f6(0xed)]()||'';for(let _0x2cdfa5 of _0x15f31c){if(!_0x2cdfa5['startsWith'](_0x4c37f6(0x6f)))continue;try{let _0x3ffab6=JSON[_0x4c37f6(0xac)](_0x2cdfa5['slice'](0x6));if(_0x3ffab6[_0x4c37f6(0xe7)]==='connected'){this[_0x4c37f6(0x8c)](_0x4c37f6(0xd5)),this[_0x4c37f6(0xb7)](_0x4c37f6(0xb0));continue;}if(_0x3ffab6[_0x4c37f6(0xe7)]===_0x4c37f6(0x77)||_0x3ffab6[_0x4c37f6(0xe7)]==='new_message'||_0x3ffab6['type']===_0x4c37f6(0xab))await this['processInbox']();}catch{}}}}catch(_0x1bd23e){if(_0x1bd23e[_0x4c37f6(0x87)]===_0x4c37f6(0xca))break;this[_0x4c37f6(0xb7)](_0x4c37f6(0xd8),_0x1bd23e),this[_0x4c37f6(0x8c)](_0x4c37f6(0x8b)+_0x1bd23e[_0x4c37f6(0xea)]);}if(this[_0x4c37f6(0xd1)])this[_0x4c37f6(0xb7)](_0x4c37f6(0x8e)),this[_0x4c37f6(0x8c)](_0x4c37f6(0xec)+_0x4d40c6/0x3e8+_0x4c37f6(0xaf)),await this[_0x4c37f6(0xd9)](_0x4d40c6),_0x4d40c6=Math[_0x4c37f6(0xdf)](_0x4d40c6*1.5,0xea60);}}async[a0_0x550e5e(0xba)](){const _0x50cf57=a0_0x550e5e;try{let _0x5a459d=(await this[_0x50cf57(0xbe)](_0x50cf57(0xe8),{'alias':this[_0x50cf57(0x7d)],'limit':0xa}))?.[_0x50cf57(0x8a)]||[];for(let _0x135885 of _0x5a459d)await this[_0x50cf57(0xbe)]('ack_inbox',{'alias':this['alias'],'message_id':_0x135885['id']}),this[_0x50cf57(0x8c)]('←\x20'+_0x135885[_0x50cf57(0x9c)]+':\x20'+_0x135885[_0x50cf57(0x78)][_0x50cf57(0xc0)](0x0,0x3c)),this[_0x50cf57(0xb7)](_0x50cf57(0x95),_0x135885),this[_0x50cf57(0xb7)](_0x50cf57(0xea),_0x135885);}catch(_0x1d6555){this[_0x50cf57(0x8c)](_0x50cf57(0xe2)+_0x1d6555[_0x50cf57(0xea)]);}}['sleep'](_0x567be2){return new Promise(_0x3e8e32=>setTimeout(_0x3e8e32,_0x567be2));}}var F=$;export{F as default,$ as CommHub};function a0_0x5bad(){const _0x1e5dcf=['CommHub\x20response\x20omitted\x20task_id','not_tracked','get_all_status','/events/','10190kBgzlD','cwd','send_failed','broadcast','parse','text','4581036MmNpDD','s...','connected','CommHub\x20rejected\x20task','completed','Bearer\x20','signal','from_alias','11FXhjQk','emit','status','stringify','processInbox','2.0','offline','report_status','call','[REDACTED]','slice','sdk-','task_id','905758VWETMy','duration_ms','registered','disconnect','task.expired','12978924lRQwpV','toAlias','AbortError','[commhub:task]\x20','2TudWVK','result','sseAbort','8757hCdqkb','message_id','running','reconnectDelay','\x20from=','string','SSE\x20connected','connectSSE','mcp_http','error','sleep','read','token','task.send.delivered','toString','send_reply','min','failed','error_code','inbox\x20error:\x20','error_message','task.send.failed','split','toTimeString','type','get_inbox','\x20error=','message','replace','SSE\x20reconnecting\x20in\x20','pop','7FxncUR','task.ack','data:\x20','parent_task_id','send','autoConnect',']\x20[commhub:','306635KSSUFa','Authorization','networkId','new_task','content','transport','agent','tools/call','unknown\x20error','alias','SSE\x20failed:\x20','parentTaskId','fromAlias','catch','4YrlMob','lifecycleTracking','\x20to=','server','\x20transport=','name','<pending>','connect','messages','SSE\x20error:\x20','log','\x20lifecycle=','disconnected','task.send.start','normal','sdk','url','missing_task_id','now','task','960780qByoeM','task.started','\x20parent_task_id=','resumeId','reply','sending','from_session','heartbeatTimer','idle','delivered','heartbeatInterval','body','5425248YGkeuV','<unknown>'];a0_0x5bad=function(){return _0x1e5dcf;};return a0_0x5bad();}
1
+ const a0_0x543c38=a0_0x24b6;(function(_0x330ca1,_0x378435){const _0x229b92=a0_0x24b6,_0x4653c7=_0x330ca1();while(!![]){try{const _0x39f05e=parseInt(_0x229b92(0xa9))/0x1+-parseInt(_0x229b92(0x88))/0x2*(-parseInt(_0x229b92(0x6d))/0x3)+parseInt(_0x229b92(0xb4))/0x4*(-parseInt(_0x229b92(0x7b))/0x5)+-parseInt(_0x229b92(0x8e))/0x6+parseInt(_0x229b92(0xc9))/0x7*(-parseInt(_0x229b92(0x91))/0x8)+parseInt(_0x229b92(0xe7))/0x9*(-parseInt(_0x229b92(0x94))/0xa)+parseInt(_0x229b92(0x80))/0xb;if(_0x39f05e===_0x378435)break;else _0x4653c7['push'](_0x4653c7['shift']());}catch(_0x46d8e2){_0x4653c7['push'](_0x4653c7['shift']());}}}(a0_0x20aa,0xf039e));import{EventEmitter as a0_0x2f0202}from'events';import{hostname as a0_0xecb4cd}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2e01f4,_0x3a7ed0)=>(_0x2e01f4??_0x3a7ed0)[a0_0x543c38(0xcf)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x543c38(0xcd)](0x0,0xf0);function a0_0x24b6(_0x23c9f8,_0x2073a7){_0x23c9f8=_0x23c9f8-0x6d;const _0x20aa0e=a0_0x20aa();let _0x24b638=_0x20aa0e[_0x23c9f8];return _0x24b638;}function N(_0x305369){const _0x51271b=a0_0x543c38;return(_0x305369 instanceof Error?_0x305369[_0x51271b(0x8f)]:String(_0x305369??_0x51271b(0xaa)))[_0x51271b(0xcf)](K,_0x51271b(0xea))[_0x51271b(0xcf)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x51271b(0xcd)](0x0,0xf0);}function O(_0x28594d,_0x6c47a5=process.env.ANET_TASK_TRACE_FORMAT===a0_0x543c38(0xce)){const _0xd03e89=a0_0x543c38;if(_0x6c47a5)return JSON[_0xd03e89(0x72)](_0x28594d);let _0x5aae20=L(_0x28594d[_0xd03e89(0x81)],_0xd03e89(0xe4)),_0x56e54e=L(_0x28594d[_0xd03e89(0x89)],_0xd03e89(0xeb)),_0x481931=_0x28594d[_0xd03e89(0x9a)]?_0xd03e89(0xc8)+_0x28594d['error_code']+':'+(_0x28594d[_0xd03e89(0xb5)]??''):'';return'[commhub:task]\x20'+_0x28594d[_0xd03e89(0x9e)]+_0xd03e89(0x90)+L(_0x28594d[_0xd03e89(0xc2)],_0xd03e89(0x79))+_0xd03e89(0xc4)+L(_0x28594d['to_alias'],_0xd03e89(0x79))+'\x20task_id='+_0x56e54e+'\x20parent_task_id='+_0x5aae20+_0xd03e89(0x75)+L(_0x28594d[_0xd03e89(0x9b)],_0xd03e89(0x79))+_0xd03e89(0xda)+_0x28594d[_0xd03e89(0xec)]+_0xd03e89(0xd4)+_0x28594d[_0xd03e89(0x6e)]+_0xd03e89(0x84)+_0x28594d['lifecycle_tracking']+_0x481931;}function U(_0x3f0154){const _0x54c059=a0_0x543c38;return{'event':{'sending':_0x54c059(0xa4),'delivered':'task.send.delivered','failed':_0x54c059(0x78),'acked':'task.ack','started':'task.started','replied':'task.replied','expired':_0x54c059(0x8a)}[_0x3f0154[_0x54c059(0x9e)]],..._0x3f0154};}function j(_0x51b3b9){const _0x5828b0=a0_0x543c38;let _0x2502e1=_0x51b3b9?.[_0x5828b0(0x89)]||_0x51b3b9?.['message_id']||_0x51b3b9?.['id'];if(_0x2502e1)return String(_0x2502e1);let _0x36e1af=_0x51b3b9?.[_0x5828b0(0x97)]?.[0x0]?.[_0x5828b0(0xc7)];if(typeof _0x36e1af!==_0x5828b0(0x86))return null;try{let _0x2b0489=JSON[_0x5828b0(0x85)](_0x36e1af);return _0x2b0489?.[_0x5828b0(0x89)]||_0x2b0489?.[_0x5828b0(0xbd)]||_0x2b0489?.['id']||null;}catch{return null;}}async function X(_0x19259f,_0x33afb3){const _0x59def9=a0_0x543c38;let _0x3df50d=_0x33afb3[_0x59def9(0xd1)]??Date[_0x59def9(0xd1)],_0x4d5721=_0x3df50d(),_0x36a84e=(_0x21ed65,_0x43048f,_0x440165,_0x1d76e9)=>{const _0x319eb8=_0x59def9;_0x33afb3[_0x319eb8(0x71)](O(U({'from_alias':_0x19259f[_0x319eb8(0xc1)],'to_alias':_0x19259f['toAlias'],'task_id':_0x43048f,'parent_task_id':_0x19259f[_0x319eb8(0xad)],'network_id':_0x19259f[_0x319eb8(0x74)],'transport':_0x19259f[_0x319eb8(0xec)],'status':_0x21ed65,'duration_ms':_0x3df50d()-_0x4d5721,'lifecycle_tracking':_0x19259f[_0x319eb8(0x73)],..._0x440165!==void 0x0?{'error_code':_0x1d76e9||_0x319eb8(0xc5),'error_message':N(_0x440165)}:{}})));};_0x36a84e(_0x59def9(0xb6),null);try{let _0x4e6ce6=await _0x33afb3[_0x59def9(0xd6)](),_0x402987=j(_0x4e6ce6);if(_0x402987)_0x36a84e(_0x59def9(0xd3),_0x402987);else{if(_0x4e6ce6?.['ok']===!0x1||_0x4e6ce6?.[_0x59def9(0xbe)])_0x36a84e('failed',_0x402987,_0x4e6ce6?.['error']||_0x59def9(0x76),_0x59def9(0xe9));else _0x36a84e(_0x59def9(0xee),null,_0x59def9(0xa7),_0x59def9(0xb7));}return _0x4e6ce6;}catch(_0x3781e6){throw _0x36a84e(_0x59def9(0xee),null,_0x3781e6,'send_failed'),_0x3781e6;}}async function Y(_0x540c32,_0x40c09b){const _0x4a3809=a0_0x543c38;return X({'fromAlias':_0x540c32[_0x4a3809(0xc1)],'toAlias':_0x540c32[_0x4a3809(0xa3)],'parentTaskId':_0x540c32[_0x4a3809(0xad)]||null,'networkId':_0x540c32['networkId']||null,'transport':_0x4a3809(0x77),'lifecycleTracking':_0x4a3809(0xe5)},_0x40c09b);}class $ extends a0_0x2f0202{[a0_0x543c38(0xcc)];[a0_0x543c38(0xa3)];[a0_0x543c38(0x7c)];['agent'];['resumeId'];[a0_0x543c38(0xa6)];['reconnectDelay'];[a0_0x543c38(0xba)];['sseAbort'];[a0_0x543c38(0xe8)]=!0x1;constructor(_0x46ef48){const _0x2b98bf=a0_0x543c38;super();if(this['url']=_0x46ef48['url'][_0x2b98bf(0xcf)](/\/$/,''),this['alias']=_0x46ef48[_0x2b98bf(0xa3)],this[_0x2b98bf(0x7c)]=_0x46ef48[_0x2b98bf(0x7c)],this['agent']=_0x46ef48['agent']||_0x2b98bf(0x83),this['resumeId']=_0x2b98bf(0xa5)+_0x46ef48[_0x2b98bf(0xa3)]+'-'+Date[_0x2b98bf(0xd1)]()[_0x2b98bf(0xd8)](0x24),this[_0x2b98bf(0xa6)]=_0x46ef48[_0x2b98bf(0xa6)]??0x2bf20,this[_0x2b98bf(0xa0)]=_0x46ef48[_0x2b98bf(0xa0)]??0xbb8,_0x46ef48[_0x2b98bf(0x8d)]!==!0x1)this[_0x2b98bf(0x70)]();}[a0_0x543c38(0x71)](_0x586227){const _0x2d149a=a0_0x543c38;console['log']('['+new Date()[_0x2d149a(0xca)]()['slice'](0x0,0x8)+_0x2d149a(0xe0)+this[_0x2d149a(0xa3)]+']\x20'+_0x586227);}async[a0_0x543c38(0xab)](_0x561374,_0x146ccd){const _0x299f85=a0_0x543c38;let _0x43a565={'Content-Type':_0x299f85(0xe3),'Accept':_0x299f85(0xcb)};if(this['token'])_0x43a565[_0x299f85(0xbc)]='Bearer\x20'+this[_0x299f85(0x7c)];let _0xb71c8b=await(await fetch(this['url']+_0x299f85(0xdb),{'method':'POST','headers':_0x43a565,'body':JSON[_0x299f85(0x72)]({'jsonrpc':'2.0','id':Date[_0x299f85(0xd1)](),'method':_0x299f85(0xdc),'params':{'name':_0x561374,'arguments':_0x146ccd}})}))[_0x299f85(0xc7)](),_0x18ae3c=_0xb71c8b[_0x299f85(0x8c)](/data: (.+)/),_0x1a0399=_0x18ae3c?JSON['parse'](_0x18ae3c[0x1]):JSON['parse'](_0xb71c8b),_0x3fe64e=_0x1a0399?.[_0x299f85(0x99)]?.['content']?.[0x0]?.[_0x299f85(0xc7)];return _0x3fe64e?JSON[_0x299f85(0x85)](_0x3fe64e):_0x1a0399;}async[a0_0x543c38(0x70)](){const _0x277496=a0_0x543c38;if(this[_0x277496(0xe8)])return;this[_0x277496(0xe8)]=!0x0,await this[_0x277496(0x9e)](_0x277496(0xb9)),this[_0x277496(0x71)](_0x277496(0xe6)),this['heartbeatTimer']=setInterval(()=>{const _0x2d5fbc=_0x277496;this[_0x2d5fbc(0x9e)](_0x2d5fbc(0xb9))[_0x2d5fbc(0xd2)](_0x26e96e=>this['log'](_0x2d5fbc(0xbf)+_0x26e96e[_0x2d5fbc(0x8f)]));},this['heartbeatInterval']),this[_0x277496(0x9f)]();}async[a0_0x543c38(0x95)](){const _0x19b8db=a0_0x543c38;if(this['running']=!0x1,this['sseAbort']?.['abort'](),this[_0x19b8db(0xba)])clearInterval(this[_0x19b8db(0xba)]);await this[_0x19b8db(0x9e)](_0x19b8db(0xdf))[_0x19b8db(0xd2)](()=>{}),this[_0x19b8db(0x71)](_0x19b8db(0xa2));}async[a0_0x543c38(0xd6)](_0x68ad89,_0x5c06c9,_0x31f997=a0_0x543c38(0x9c)){const _0x5c8aca=a0_0x543c38;return Y({'alias':_0x68ad89,'fromAlias':this[_0x5c8aca(0xa3)]},{'log':_0x57c670=>console[_0x5c8aca(0x71)](_0x57c670),'send':()=>this['call'](_0x5c8aca(0x82),{'alias':_0x68ad89,'task':_0x5c06c9,'priority':_0x31f997,'from_session':this[_0x5c8aca(0xa3)]})});}async['message'](_0x35441a,_0x3ee095){const _0x36ee6f=a0_0x543c38;return this[_0x36ee6f(0xab)](_0x36ee6f(0x7a),{'alias':_0x35441a,'message':_0x3ee095,'from_session':this['alias']});}async[a0_0x543c38(0xc6)](_0x52e19a,_0x4326b8,_0x463363=a0_0x543c38(0xd0)){const _0x2741d6=a0_0x543c38;return this[_0x2741d6(0xab)](_0x2741d6(0x93),{'in_reply_to':_0x52e19a,'text':_0x4326b8,'status':_0x463363});}async['status'](_0x400527,_0x558764){const _0x3b107f=a0_0x543c38;return this[_0x3b107f(0xab)](_0x3b107f(0xd5),{'resume_id':this['resumeId'],'alias':this[_0x3b107f(0xa3)],'status':_0x400527,'server':a0_0xecb4cd(),'hostname':a0_0xecb4cd(),'agent':this[_0x3b107f(0xd9)],'project_dir':process[_0x3b107f(0xbb)](),..._0x558764});}async[a0_0x543c38(0xb2)](){const _0x4dda67=a0_0x543c38;return this[_0x4dda67(0xab)]('get_all_status',{});}async[a0_0x543c38(0xd7)](_0x1342ed,_0x43e63d){const _0x22a2a6=a0_0x543c38;return this[_0x22a2a6(0xab)](_0x22a2a6(0xd7),{'message':_0x1342ed,'filter_server':_0x43e63d?.['server'],'filter_status':_0x43e63d?.[_0x22a2a6(0x9e)]});}async[a0_0x543c38(0x9f)](){const _0x50e046=a0_0x543c38;let _0x444979=encodeURIComponent(this['alias']),_0x11783e=this[_0x50e046(0xcc)]+_0x50e046(0x92)+_0x444979,_0x52d6c0=this[_0x50e046(0xa0)];while(this[_0x50e046(0xe8)]){try{this['sseAbort']=new AbortController();let _0x1fb1b2={'Accept':'text/event-stream'};if(this[_0x50e046(0x7c)])_0x1fb1b2[_0x50e046(0xbc)]=_0x50e046(0xa8)+this['token'];let _0x26de69=await fetch(_0x11783e,{'headers':_0x1fb1b2,'signal':this[_0x50e046(0xc3)][_0x50e046(0xdd)]});if(!_0x26de69['ok']||!_0x26de69[_0x50e046(0xaf)]){this[_0x50e046(0x71)](_0x50e046(0xed)+_0x26de69['status']),await this['sleep'](_0x52d6c0),_0x52d6c0=Math['min'](_0x52d6c0*1.5,0xea60);continue;}_0x52d6c0=this[_0x50e046(0xa0)];let _0x3b9f74=_0x26de69['body'][_0x50e046(0x98)](),_0x28a611=new TextDecoder(),_0x1ec1e3='';while(this[_0x50e046(0xe8)]){let {done:_0x5442bc,value:_0x25e9cc}=await _0x3b9f74[_0x50e046(0xae)]();if(_0x5442bc)break;_0x1ec1e3+=_0x28a611[_0x50e046(0x7e)](_0x25e9cc,{'stream':!0x0});let _0x2100ae=_0x1ec1e3['split']('\x0a');_0x1ec1e3=_0x2100ae[_0x50e046(0xac)]()||'';for(let _0x3d9b45 of _0x2100ae){if(!_0x3d9b45[_0x50e046(0xe2)](_0x50e046(0x87)))continue;try{let _0x2a0f22=JSON[_0x50e046(0x85)](_0x3d9b45[_0x50e046(0xcd)](0x6));if(_0x2a0f22[_0x50e046(0x96)]==='connected'){this['log'](_0x50e046(0xa1)),this[_0x50e046(0x7d)](_0x50e046(0xb0));continue;}if(_0x2a0f22[_0x50e046(0x96)]==='new_task'||_0x2a0f22['type']===_0x50e046(0xb1)||_0x2a0f22[_0x50e046(0x96)]===_0x50e046(0xd7))await this[_0x50e046(0x6f)]();}catch{}}}}catch(_0x1653da){if(_0x1653da['name']==='AbortError')break;this[_0x50e046(0x7d)]('error',_0x1653da),this[_0x50e046(0x71)](_0x50e046(0xb3)+_0x1653da[_0x50e046(0x8f)]);}if(this[_0x50e046(0xe8)])this[_0x50e046(0x7d)]('disconnected'),this[_0x50e046(0x71)](_0x50e046(0xde)+_0x52d6c0/0x3e8+_0x50e046(0x8b)),await this[_0x50e046(0x7f)](_0x52d6c0),_0x52d6c0=Math[_0x50e046(0xc0)](_0x52d6c0*1.5,0xea60);}}async[a0_0x543c38(0x6f)](){const _0x22073d=a0_0x543c38;try{let _0x462c96=(await this[_0x22073d(0xab)]('get_inbox',{'alias':this['alias'],'limit':0xa}))?.[_0x22073d(0xb8)]||[];for(let _0x24df74 of _0x462c96)await this[_0x22073d(0xab)]('ack_inbox',{'alias':this[_0x22073d(0xa3)],'message_id':_0x24df74['id']}),this[_0x22073d(0x71)]('←\x20'+_0x24df74[_0x22073d(0x9d)]+':\x20'+_0x24df74[_0x22073d(0x97)][_0x22073d(0xcd)](0x0,0x3c)),this['emit'](_0x22073d(0xe1),_0x24df74),this[_0x22073d(0x7d)](_0x22073d(0x8f),_0x24df74);}catch(_0x39a0eb){this[_0x22073d(0x71)]('inbox\x20error:\x20'+_0x39a0eb[_0x22073d(0x8f)]);}}[a0_0x543c38(0x7f)](_0x4e318a){return new Promise(_0x5987ed=>setTimeout(_0x5987ed,_0x4e318a));}}var F=$;function a0_0x20aa(){const _0x20fa1f=['sdk','\x20lifecycle=','parse','string','data:\x20','1481606nFUBmQ','task_id','task.expired','s...','match','autoConnect','171234oCWWdz','message','\x20from=','1175896zSpnFM','/events/','send_reply','10ubNzkS','disconnect','type','content','getReader','result','error_code','network_id','normal','from_session','status','connectSSE','reconnectDelay','SSE\x20connected','disconnected','alias','task.send.start','sdk-','heartbeatInterval','CommHub\x20response\x20omitted\x20task_id','Bearer\x20','213975zYuNoK','unknown\x20error','call','pop','parentTaskId','read','body','connected','new_message','getAllStatus','SSE\x20error:\x20','283516zEnzUC','error_message','sending','missing_task_id','messages','idle','heartbeatTimer','cwd','Authorization','message_id','error','heartbeat\x20failed:\x20','min','fromAlias','from_alias','sseAbort','\x20to=','send_failed','reply','text','\x20error=','91KWjxVT','toTimeString','application/json,\x20text/event-stream','url','slice','json','replace','completed','now','catch','delivered','\x20duration_ms=','report_status','send','broadcast','toString','agent','\x20transport=','/mcp','tools/call','signal','SSE\x20reconnecting\x20in\x20','offline',']\x20[commhub:','task','startsWith','application/json','<missing>','not_tracked','registered','9417186hxAbVY','running','send_rejected','[REDACTED]','<pending>','transport','SSE\x20failed:\x20','failed','3CPxINe','duration_ms','processInbox','connect','log','stringify','lifecycleTracking','networkId','\x20network_id=','CommHub\x20rejected\x20task','mcp_http','task.send.failed','<unknown>','send_message','95DOUfhS','token','emit','decode','sleep','47977743wXsRmV','parent_task_id','send_task'];a0_0x20aa=function(){return _0x20fa1f;};return a0_0x20aa();}export{F as default,$ as CommHub};