@sleep2agi/agent-network 2.3.0-preview.182 → 2.3.0-preview.184

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_0x272b16=a0_0x39a9;(function(_0x228720,_0xb42387){const _0x1efa33=a0_0x39a9,_0x5df8b5=_0x228720();while(!![]){try{const _0x578b08=-parseInt(_0x1efa33(0xe9))/0x1*(parseInt(_0x1efa33(0xf4))/0x2)+-parseInt(_0x1efa33(0x144))/0x3*(-parseInt(_0x1efa33(0xef))/0x4)+-parseInt(_0x1efa33(0xd8))/0x5+parseInt(_0x1efa33(0x122))/0x6+parseInt(_0x1efa33(0x11c))/0x7+parseInt(_0x1efa33(0x134))/0x8*(-parseInt(_0x1efa33(0xd6))/0x9)+parseInt(_0x1efa33(0xe2))/0xa;if(_0x578b08===_0xb42387)break;else _0x5df8b5['push'](_0x5df8b5['shift']());}catch(_0x17b8d1){_0x5df8b5['push'](_0x5df8b5['shift']());}}}(a0_0x4c4b,0x8e650));import{EventEmitter as a0_0x118283}from'events';import{hostname as a0_0xcf1272}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x5a7b6d,_0x28fe92)=>(_0x5a7b6d??_0x28fe92)[a0_0x272b16(0x12b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x272b16(0x13c)](0x0,0xf0);function N(_0x2f223e){const _0x2c47ee=a0_0x272b16;return(_0x2f223e instanceof Error?_0x2f223e['message']:String(_0x2f223e??_0x2c47ee(0xe1)))['replace'](K,_0x2c47ee(0x104))[_0x2c47ee(0x12b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x2c47ee(0x13c)](0x0,0xf0);}function O(_0x5f1e83,_0xc81180=process.env.ANET_TASK_TRACE_FORMAT===a0_0x272b16(0x10e)){const _0x1df865=a0_0x272b16;if(_0xc81180)return JSON[_0x1df865(0x115)](_0x5f1e83);let _0x2fc3c6=L(_0x5f1e83[_0x1df865(0x141)],'<missing>'),_0x4d4ba7=L(_0x5f1e83[_0x1df865(0xfd)],_0x1df865(0x100)),_0x3f4792=_0x5f1e83[_0x1df865(0x12a)]?_0x1df865(0xe5)+_0x5f1e83[_0x1df865(0x12a)]+':'+(_0x5f1e83[_0x1df865(0xdc)]??''):'';return'[commhub:task]\x20'+_0x5f1e83[_0x1df865(0xd4)]+_0x1df865(0xce)+L(_0x5f1e83['from_alias'],_0x1df865(0x109))+_0x1df865(0x117)+L(_0x5f1e83[_0x1df865(0xf6)],_0x1df865(0x109))+_0x1df865(0xd2)+_0x4d4ba7+'\x20parent_task_id='+_0x2fc3c6+_0x1df865(0xe3)+L(_0x5f1e83['network_id'],_0x1df865(0x109))+'\x20transport='+_0x5f1e83[_0x1df865(0x132)]+_0x1df865(0xcd)+_0x5f1e83['duration_ms']+'\x20lifecycle='+_0x5f1e83[_0x1df865(0xec)]+_0x3f4792;}function U(_0x35941a){const _0xa9f8b2=a0_0x272b16;return{'event':{'sending':_0xa9f8b2(0x133),'delivered':_0xa9f8b2(0x11a),'failed':_0xa9f8b2(0xe8),'acked':_0xa9f8b2(0x114),'started':'task.started','replied':_0xa9f8b2(0x10d),'expired':_0xa9f8b2(0x13e)}[_0x35941a[_0xa9f8b2(0xd4)]],..._0x35941a};}function j(_0x339724){const _0x5d5650=a0_0x272b16;let _0x954df8=_0x339724?.[_0x5d5650(0xfd)]||_0x339724?.[_0x5d5650(0x107)]||_0x339724?.['id'];if(_0x954df8)return String(_0x954df8);let _0x530762=_0x339724?.[_0x5d5650(0xd5)]?.[0x0]?.[_0x5d5650(0x125)];if(typeof _0x530762!==_0x5d5650(0x10a))return null;try{let _0x276ed4=JSON[_0x5d5650(0xf8)](_0x530762);return _0x276ed4?.[_0x5d5650(0xfd)]||_0x276ed4?.['message_id']||_0x276ed4?.['id']||null;}catch{return null;}}async function X(_0x195757,_0x328eea){const _0x197d40=a0_0x272b16;let _0x5a2a31=_0x328eea[_0x197d40(0x140)]??Date[_0x197d40(0x140)],_0x3260a6=_0x5a2a31(),_0x2ebb66=(_0x4838d3,_0x3b6388,_0x539ee4,_0x382b84)=>{const _0x512a7d=_0x197d40;_0x328eea[_0x512a7d(0xd3)](O(U({'from_alias':_0x195757[_0x512a7d(0xe0)],'to_alias':_0x195757['toAlias'],'task_id':_0x3b6388,'parent_task_id':_0x195757[_0x512a7d(0x119)],'network_id':_0x195757['networkId'],'transport':_0x195757[_0x512a7d(0x132)],'status':_0x4838d3,'duration_ms':_0x5a2a31()-_0x3260a6,'lifecycle_tracking':_0x195757[_0x512a7d(0xf9)],..._0x539ee4!==void 0x0?{'error_code':_0x382b84||_0x512a7d(0x123),'error_message':N(_0x539ee4)}:{}})));};_0x2ebb66(_0x197d40(0xe6),null);try{let _0x5a5809=await _0x328eea['send'](),_0x3f1e63=j(_0x5a5809);if(_0x3f1e63)_0x2ebb66('delivered',_0x3f1e63);else{if(_0x5a5809?.['ok']===!0x1||_0x5a5809?.['error'])_0x2ebb66(_0x197d40(0x120),_0x3f1e63,_0x5a5809?.['error']||_0x197d40(0x13b),_0x197d40(0x135));else _0x2ebb66('failed',null,'CommHub\x20response\x20omitted\x20task_id','missing_task_id');}return _0x5a5809;}catch(_0x1fd465){throw _0x2ebb66('failed',null,_0x1fd465,_0x197d40(0x123)),_0x1fd465;}}async function Y(_0x1eed83,_0x26a584){const _0x2e07b4=a0_0x272b16;return X({'fromAlias':_0x1eed83[_0x2e07b4(0xe0)],'toAlias':_0x1eed83[_0x2e07b4(0x11e)],'parentTaskId':_0x1eed83[_0x2e07b4(0x119)]||null,'networkId':_0x1eed83['networkId']||null,'transport':_0x2e07b4(0xd9),'lifecycleTracking':_0x2e07b4(0x121)},_0x26a584);}class $ extends a0_0x118283{[a0_0x272b16(0xfa)];[a0_0x272b16(0x11e)];['token'];[a0_0x272b16(0xf2)];['resumeId'];['heartbeatInterval'];['reconnectDelay'];[a0_0x272b16(0x110)];[a0_0x272b16(0xf1)];[a0_0x272b16(0xd1)]=!0x1;constructor(_0x1f6853){const _0x19f57e=a0_0x272b16;super();if(this[_0x19f57e(0xfa)]=_0x1f6853[_0x19f57e(0xfa)][_0x19f57e(0x12b)](/\/$/,''),this[_0x19f57e(0x11e)]=_0x1f6853[_0x19f57e(0x11e)],this['token']=_0x1f6853[_0x19f57e(0x11f)],this[_0x19f57e(0xf2)]=_0x1f6853['agent']||'sdk',this['resumeId']=_0x19f57e(0xf0)+_0x1f6853['alias']+'-'+Date['now']()['toString'](0x24),this[_0x19f57e(0x12c)]=_0x1f6853[_0x19f57e(0x12c)]??0x2bf20,this[_0x19f57e(0x128)]=_0x1f6853[_0x19f57e(0x128)]??0xbb8,_0x1f6853[_0x19f57e(0x10b)]!==!0x1)this['connect']();}[a0_0x272b16(0xd3)](_0x251477){const _0x2d6208=a0_0x272b16;console[_0x2d6208(0xd3)]('['+new Date()[_0x2d6208(0x136)]()[_0x2d6208(0x13c)](0x0,0x8)+']\x20[commhub:'+this['alias']+']\x20'+_0x251477);}async[a0_0x272b16(0xed)](_0x4e0bad,_0x48c5db){const _0x5b08d8=a0_0x272b16;let _0x18719a={'Content-Type':_0x5b08d8(0xda),'Accept':_0x5b08d8(0x12e)};if(this[_0x5b08d8(0x11f)])_0x18719a['Authorization']=_0x5b08d8(0xee)+this[_0x5b08d8(0x11f)];let _0x4fcafa=await(await fetch(this[_0x5b08d8(0xfa)]+_0x5b08d8(0xfe),{'method':_0x5b08d8(0xff),'headers':_0x18719a,'body':JSON[_0x5b08d8(0x115)]({'jsonrpc':'2.0','id':Date['now'](),'method':_0x5b08d8(0x116),'params':{'name':_0x4e0bad,'arguments':_0x48c5db}})}))[_0x5b08d8(0x125)](),_0x5f11fc=_0x4fcafa[_0x5b08d8(0x106)](/data: (.+)/),_0x5e38dd=_0x5f11fc?JSON[_0x5b08d8(0xf8)](_0x5f11fc[0x1]):JSON[_0x5b08d8(0xf8)](_0x4fcafa),_0x5ad017=_0x5e38dd?.[_0x5b08d8(0xcf)]?.[_0x5b08d8(0xd5)]?.[0x0]?.[_0x5b08d8(0x125)];return _0x5ad017?JSON[_0x5b08d8(0xf8)](_0x5ad017):_0x5e38dd;}async[a0_0x272b16(0x113)](){const _0x33c4bb=a0_0x272b16;if(this[_0x33c4bb(0xd1)])return;this[_0x33c4bb(0xd1)]=!0x0,await this[_0x33c4bb(0xd4)]('idle'),this[_0x33c4bb(0xd3)]('registered'),this[_0x33c4bb(0x110)]=setInterval(()=>{const _0x244cfe=_0x33c4bb;this[_0x244cfe(0xd4)](_0x244cfe(0xea))[_0x244cfe(0xd0)](_0x28c3c8=>this[_0x244cfe(0xd3)](_0x244cfe(0x118)+_0x28c3c8[_0x244cfe(0x103)]));},this['heartbeatInterval']),this[_0x33c4bb(0x10f)]();}async['disconnect'](){const _0x5186c4=a0_0x272b16;if(this[_0x5186c4(0xd1)]=!0x1,this[_0x5186c4(0xf1)]?.[_0x5186c4(0xd7)](),this[_0x5186c4(0x110)])clearInterval(this[_0x5186c4(0x110)]);await this[_0x5186c4(0xd4)](_0x5186c4(0x11b))[_0x5186c4(0xd0)](()=>{}),this[_0x5186c4(0xd3)](_0x5186c4(0xdb));}async[a0_0x272b16(0x105)](_0x490db8,_0x3d1ae6,_0x292c89='normal'){const _0x49ba99=a0_0x272b16;return Y({'alias':_0x490db8,'fromAlias':this[_0x49ba99(0x11e)]},{'log':_0xf9a978=>console['log'](_0xf9a978),'send':()=>this[_0x49ba99(0xed)]('send_task',{'alias':_0x490db8,'task':_0x3d1ae6,'priority':_0x292c89,'from_session':this[_0x49ba99(0x11e)]})});}async[a0_0x272b16(0x103)](_0x2b8ef5,_0x29e79e){const _0xdf15b8=a0_0x272b16;return this[_0xdf15b8(0xed)](_0xdf15b8(0x13f),{'alias':_0x2b8ef5,'message':_0x29e79e,'from_session':this[_0xdf15b8(0x11e)]});}async['reply'](_0x4944cd,_0x15b034,_0xb36331=a0_0x272b16(0x10c)){const _0x35b24d=a0_0x272b16;return this[_0x35b24d(0xed)](_0x35b24d(0xf7),{'in_reply_to':_0x4944cd,'text':_0x15b034,'status':_0xb36331});}async[a0_0x272b16(0xd4)](_0x1c76b1,_0x7a6ce9){const _0x1174ce=a0_0x272b16;return this[_0x1174ce(0xed)](_0x1174ce(0x142),{'resume_id':this[_0x1174ce(0x131)],'alias':this[_0x1174ce(0x11e)],'status':_0x1c76b1,'server':a0_0xcf1272(),'hostname':a0_0xcf1272(),'agent':this[_0x1174ce(0xf2)],'project_dir':process['cwd'](),..._0x7a6ce9});}async[a0_0x272b16(0x127)](){const _0x38ac2f=a0_0x272b16;return this[_0x38ac2f(0xed)](_0x38ac2f(0xdf),{});}async[a0_0x272b16(0x124)](_0x4db7a5,_0x4156b8){const _0x1e0973=a0_0x272b16;return this['call'](_0x1e0973(0x124),{'message':_0x4db7a5,'filter_server':_0x4156b8?.[_0x1e0973(0x101)],'filter_status':_0x4156b8?.[_0x1e0973(0xd4)]});}async['connectSSE'](){const _0x59d162=a0_0x272b16;let _0x2b9394=encodeURIComponent(this[_0x59d162(0x11e)]),_0x422fbd=this['url']+'/events/'+_0x2b9394,_0x5a48ab=this[_0x59d162(0x128)];while(this[_0x59d162(0xd1)]){try{this['sseAbort']=new AbortController();let _0x13c024={'Accept':_0x59d162(0x13d)};if(this[_0x59d162(0x11f)])_0x13c024['Authorization']='Bearer\x20'+this[_0x59d162(0x11f)];let _0x98c9ca=await fetch(_0x422fbd,{'headers':_0x13c024,'signal':this[_0x59d162(0xf1)][_0x59d162(0x112)]});if(!_0x98c9ca['ok']||!_0x98c9ca[_0x59d162(0x129)]){this[_0x59d162(0xd3)](_0x59d162(0xe7)+_0x98c9ca[_0x59d162(0xd4)]),await this[_0x59d162(0x130)](_0x5a48ab),_0x5a48ab=Math[_0x59d162(0x12f)](_0x5a48ab*1.5,0xea60);continue;}_0x5a48ab=this[_0x59d162(0x128)];let _0x115b6b=_0x98c9ca[_0x59d162(0x129)][_0x59d162(0x137)](),_0x3970d6=new TextDecoder(),_0xfaec9b='';while(this[_0x59d162(0xd1)]){let {done:_0x33f9ba,value:_0x25fc65}=await _0x115b6b['read']();if(_0x33f9ba)break;_0xfaec9b+=_0x3970d6['decode'](_0x25fc65,{'stream':!0x0});let _0x390ba1=_0xfaec9b[_0x59d162(0x126)]('\x0a');_0xfaec9b=_0x390ba1[_0x59d162(0xfb)]()||'';for(let _0x1a4350 of _0x390ba1){if(!_0x1a4350['startsWith'](_0x59d162(0xdd)))continue;try{let _0x3d3585=JSON[_0x59d162(0xf8)](_0x1a4350['slice'](0x6));if(_0x3d3585[_0x59d162(0x138)]===_0x59d162(0xf5)){this['log'](_0x59d162(0xfc)),this['emit'](_0x59d162(0xf5));continue;}if(_0x3d3585[_0x59d162(0x138)]==='new_task'||_0x3d3585[_0x59d162(0x138)]===_0x59d162(0xf3)||_0x3d3585[_0x59d162(0x138)]===_0x59d162(0x124))await this[_0x59d162(0x12d)]();}catch{}}}}catch(_0x4d4c27){if(_0x4d4c27[_0x59d162(0xe4)]===_0x59d162(0x108))break;this[_0x59d162(0xde)](_0x59d162(0x111),_0x4d4c27),this[_0x59d162(0xd3)](_0x59d162(0x102)+_0x4d4c27[_0x59d162(0x103)]);}if(this[_0x59d162(0xd1)])this[_0x59d162(0xde)](_0x59d162(0xdb)),this['log'](_0x59d162(0x11d)+_0x5a48ab/0x3e8+_0x59d162(0x13a)),await this[_0x59d162(0x130)](_0x5a48ab),_0x5a48ab=Math[_0x59d162(0x12f)](_0x5a48ab*1.5,0xea60);}}async['processInbox'](){const _0x32801b=a0_0x272b16;try{let _0x34ab7c=(await this[_0x32801b(0xed)](_0x32801b(0x143),{'alias':this[_0x32801b(0x11e)],'limit':0xa}))?.[_0x32801b(0x139)]||[];for(let _0x3a52d4 of _0x34ab7c)await this[_0x32801b(0xed)]('ack_inbox',{'alias':this['alias'],'message_id':_0x3a52d4['id']}),this[_0x32801b(0xd3)]('←\x20'+_0x3a52d4[_0x32801b(0xeb)]+':\x20'+_0x3a52d4[_0x32801b(0xd5)][_0x32801b(0x13c)](0x0,0x3c)),this[_0x32801b(0xde)]('task',_0x3a52d4),this[_0x32801b(0xde)](_0x32801b(0x103),_0x3a52d4);}catch(_0x189603){this[_0x32801b(0xd3)]('inbox\x20error:\x20'+_0x189603[_0x32801b(0x103)]);}}[a0_0x272b16(0x130)](_0x44e3e3){return new Promise(_0x13d7a9=>setTimeout(_0x13d7a9,_0x44e3e3));}}function a0_0x39a9(_0x2e690b,_0x25daf0){_0x2e690b=_0x2e690b-0xcd;const _0x4c4b51=a0_0x4c4b();let _0x39a9dd=_0x4c4b51[_0x2e690b];return _0x39a9dd;}var F=$;export{F as default,$ as CommHub};function a0_0x4c4b(){const _0x3855ff=['failed','not_tracked','4104774GMBTNG','send_failed','broadcast','text','split','getAllStatus','reconnectDelay','body','error_code','replace','heartbeatInterval','processInbox','application/json,\x20text/event-stream','min','sleep','resumeId','transport','task.send.start','247152HkrfPj','send_rejected','toTimeString','getReader','type','messages','s...','CommHub\x20rejected\x20task','slice','text/event-stream','task.expired','send_message','now','parent_task_id','report_status','get_inbox','3FABeIc','\x20duration_ms=','\x20from=','result','catch','running','\x20task_id=','log','status','content','252cJkZvE','abort','1097330riagYz','mcp_http','application/json','disconnected','error_message','data:\x20','emit','get_all_status','fromAlias','unknown\x20error','8472280dNkAFS','\x20network_id=','name','\x20error=','sending','SSE\x20failed:\x20','task.send.failed','71700htYTjB','idle','from_session','lifecycle_tracking','call','Bearer\x20','2607916BtUUIv','sdk-','sseAbort','agent','new_message','24sLwFhI','connected','to_alias','send_reply','parse','lifecycleTracking','url','pop','SSE\x20connected','task_id','/mcp','POST','<pending>','server','SSE\x20error:\x20','message','[REDACTED]','send','match','message_id','AbortError','<unknown>','string','autoConnect','completed','task.replied','json','connectSSE','heartbeatTimer','error','signal','connect','task.ack','stringify','tools/call','\x20to=','heartbeat\x20failed:\x20','parentTaskId','task.send.delivered','offline','2413670MFwwbg','SSE\x20reconnecting\x20in\x20','alias','token'];a0_0x4c4b=function(){return _0x3855ff;};return a0_0x4c4b();}
1
+ const a0_0x2eb4c7=a0_0x337c;(function(_0x1e804b,_0x5d505d){const _0x2b5448=a0_0x337c,_0x6cd885=_0x1e804b();while(!![]){try{const _0x3f0c7d=parseInt(_0x2b5448(0x1a6))/0x1+-parseInt(_0x2b5448(0x188))/0x2+-parseInt(_0x2b5448(0x19d))/0x3+-parseInt(_0x2b5448(0x173))/0x4*(-parseInt(_0x2b5448(0x16b))/0x5)+parseInt(_0x2b5448(0x156))/0x6*(parseInt(_0x2b5448(0x1a8))/0x7)+-parseInt(_0x2b5448(0x1ae))/0x8*(parseInt(_0x2b5448(0x17d))/0x9)+parseInt(_0x2b5448(0x161))/0xa;if(_0x3f0c7d===_0x5d505d)break;else _0x6cd885['push'](_0x6cd885['shift']());}catch(_0x178423){_0x6cd885['push'](_0x6cd885['shift']());}}}(a0_0x141b,0x99ee1));import{EventEmitter as a0_0x4ff83b}from'events';import{hostname as a0_0x116f3d}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x624f4b,_0x151779)=>(_0x624f4b??_0x151779)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x2eb4c7(0x16c)](0x0,0xf0);function N(_0x95f33f){const _0x20209b=a0_0x2eb4c7;return(_0x95f33f instanceof Error?_0x95f33f['message']:String(_0x95f33f??_0x20209b(0x186)))[_0x20209b(0x178)](K,_0x20209b(0x155))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x30ecb1,_0x4f7058=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2eb4c7(0x153)){const _0x98bb93=a0_0x2eb4c7;if(_0x4f7058)return JSON[_0x98bb93(0x16e)](_0x30ecb1);let _0x1f876d=L(_0x30ecb1[_0x98bb93(0x17f)],_0x98bb93(0x1c0)),_0x4ff64c=L(_0x30ecb1['task_id'],_0x98bb93(0x1ac)),_0x20942d=_0x30ecb1[_0x98bb93(0x1c3)]?'\x20error='+_0x30ecb1[_0x98bb93(0x1c3)]+':'+(_0x30ecb1[_0x98bb93(0x1b7)]??''):'';return _0x98bb93(0x179)+_0x30ecb1[_0x98bb93(0x18b)]+'\x20from='+L(_0x30ecb1['from_alias'],_0x98bb93(0x1bf))+'\x20to='+L(_0x30ecb1[_0x98bb93(0x154)],'<unknown>')+_0x98bb93(0x1b6)+_0x4ff64c+_0x98bb93(0x1c9)+_0x1f876d+_0x98bb93(0x1c4)+L(_0x30ecb1[_0x98bb93(0x171)],_0x98bb93(0x1bf))+_0x98bb93(0x194)+_0x30ecb1['transport']+_0x98bb93(0x18a)+_0x30ecb1[_0x98bb93(0x193)]+'\x20lifecycle='+_0x30ecb1[_0x98bb93(0x17e)]+_0x20942d;}function U(_0x19d99a){const _0x2c846d=a0_0x2eb4c7;return{'event':{'sending':'task.send.start','delivered':_0x2c846d(0x1bc),'failed':'task.send.failed','acked':_0x2c846d(0x1b9),'started':'task.started','replied':_0x2c846d(0x16d),'expired':'task.expired'}[_0x19d99a['status']],..._0x19d99a};}function j(_0x13e606){const _0x8a9485=a0_0x2eb4c7;let _0x4443ef=_0x13e606?.['task_id']||_0x13e606?.['message_id']||_0x13e606?.['id'];if(_0x4443ef)return String(_0x4443ef);let _0x56355a=_0x13e606?.['content']?.[0x0]?.['text'];if(typeof _0x56355a!==_0x8a9485(0x185))return null;try{let _0x72185a=JSON['parse'](_0x56355a);return _0x72185a?.['task_id']||_0x72185a?.['message_id']||_0x72185a?.['id']||null;}catch{return null;}}async function X(_0x5767e4,_0x28db05){const _0x2725dd=a0_0x2eb4c7;let _0x1cb674=_0x28db05[_0x2725dd(0x167)]??Date['now'],_0x8d3945=_0x1cb674(),_0x1c04a2=(_0x173757,_0x496ac3,_0x2c8a00,_0x3764a4)=>{const _0x16a0a9=_0x2725dd;_0x28db05[_0x16a0a9(0x1af)](O(U({'from_alias':_0x5767e4[_0x16a0a9(0x1c6)],'to_alias':_0x5767e4['toAlias'],'task_id':_0x496ac3,'parent_task_id':_0x5767e4[_0x16a0a9(0x1c1)],'network_id':_0x5767e4[_0x16a0a9(0x197)],'transport':_0x5767e4[_0x16a0a9(0x19f)],'status':_0x173757,'duration_ms':_0x1cb674()-_0x8d3945,'lifecycle_tracking':_0x5767e4[_0x16a0a9(0x1ca)],..._0x2c8a00!==void 0x0?{'error_code':_0x3764a4||_0x16a0a9(0x17b),'error_message':N(_0x2c8a00)}:{}})));};_0x1c04a2(_0x2725dd(0x187),null);try{let _0x4614ef=await _0x28db05['send'](),_0x2e993e=j(_0x4614ef);if(_0x2e993e)_0x1c04a2(_0x2725dd(0x1bd),_0x2e993e);else{if(_0x4614ef?.['ok']===!0x1||_0x4614ef?.['error'])_0x1c04a2('failed',_0x2e993e,_0x4614ef?.[_0x2725dd(0x1c2)]||_0x2725dd(0x1a0),_0x2725dd(0x1a2));else _0x1c04a2(_0x2725dd(0x15f),null,'CommHub\x20response\x20omitted\x20task_id',_0x2725dd(0x18e));}return _0x4614ef;}catch(_0x5d1b0b){throw _0x1c04a2('failed',null,_0x5d1b0b,_0x2725dd(0x17b)),_0x5d1b0b;}}async function Y(_0x346077,_0x2591ad){const _0x1a8a43=a0_0x2eb4c7;return X({'fromAlias':_0x346077[_0x1a8a43(0x1c6)],'toAlias':_0x346077[_0x1a8a43(0x18f)],'parentTaskId':_0x346077[_0x1a8a43(0x1c1)]||null,'networkId':_0x346077[_0x1a8a43(0x197)]||null,'transport':_0x1a8a43(0x1c5),'lifecycleTracking':_0x1a8a43(0x17c)},_0x2591ad);}function a0_0x337c(_0x2f2c7c,_0x40324a){_0x2f2c7c=_0x2f2c7c-0x151;const _0x141bc1=a0_0x141b();let _0x337c32=_0x141bc1[_0x2f2c7c];return _0x337c32;}class $ extends a0_0x4ff83b{['url'];[a0_0x2eb4c7(0x18f)];['token'];[a0_0x2eb4c7(0x170)];['resumeId'];['heartbeatInterval'];['reconnectDelay'];[a0_0x2eb4c7(0x183)];[a0_0x2eb4c7(0x1b8)];['running']=!0x1;constructor(_0xd1e618){const _0x504f9f=a0_0x2eb4c7;super();if(this['url']=_0xd1e618[_0x504f9f(0x157)][_0x504f9f(0x178)](/\/$/,''),this[_0x504f9f(0x18f)]=_0xd1e618[_0x504f9f(0x18f)],this['token']=_0xd1e618[_0x504f9f(0x1b1)],this[_0x504f9f(0x170)]=_0xd1e618[_0x504f9f(0x170)]||_0x504f9f(0x165),this[_0x504f9f(0x192)]='sdk-'+_0xd1e618[_0x504f9f(0x18f)]+'-'+Date[_0x504f9f(0x167)]()[_0x504f9f(0x1a9)](0x24),this[_0x504f9f(0x15a)]=_0xd1e618[_0x504f9f(0x15a)]??0x2bf20,this[_0x504f9f(0x160)]=_0xd1e618[_0x504f9f(0x160)]??0xbb8,_0xd1e618[_0x504f9f(0x163)]!==!0x1)this[_0x504f9f(0x174)]();}[a0_0x2eb4c7(0x1af)](_0x11952e){const _0xc08f82=a0_0x2eb4c7;console['log']('['+new Date()[_0xc08f82(0x180)]()['slice'](0x0,0x8)+']\x20[commhub:'+this[_0xc08f82(0x18f)]+']\x20'+_0x11952e);}async['call'](_0x309a2a,_0x55107c){const _0x559a9d=a0_0x2eb4c7;let _0x212d83={'Content-Type':_0x559a9d(0x1a7),'Accept':'application/json,\x20text/event-stream'};if(this[_0x559a9d(0x1b1)])_0x212d83[_0x559a9d(0x190)]=_0x559a9d(0x166)+this['token'];let _0x48fa61=await(await fetch(this[_0x559a9d(0x157)]+_0x559a9d(0x15d),{'method':_0x559a9d(0x16f),'headers':_0x212d83,'body':JSON[_0x559a9d(0x16e)]({'jsonrpc':'2.0','id':Date[_0x559a9d(0x167)](),'method':_0x559a9d(0x191),'params':{'name':_0x309a2a,'arguments':_0x55107c}})}))[_0x559a9d(0x1b4)](),_0x53202f=_0x48fa61[_0x559a9d(0x158)](/data: (.+)/),_0x4df14a=_0x53202f?JSON[_0x559a9d(0x199)](_0x53202f[0x1]):JSON[_0x559a9d(0x199)](_0x48fa61),_0x529a79=_0x4df14a?.['result']?.['content']?.[0x0]?.[_0x559a9d(0x1b4)];return _0x529a79?JSON[_0x559a9d(0x199)](_0x529a79):_0x4df14a;}async[a0_0x2eb4c7(0x174)](){const _0x75c740=a0_0x2eb4c7;if(this[_0x75c740(0x15b)])return;this['running']=!0x0,await this[_0x75c740(0x18b)](_0x75c740(0x168)),this[_0x75c740(0x1af)]('registered'),this[_0x75c740(0x183)]=setInterval(()=>{const _0x3248f5=_0x75c740;this[_0x3248f5(0x18b)](_0x3248f5(0x168))[_0x3248f5(0x1be)](_0x5ed12a=>this['log'](_0x3248f5(0x19c)+_0x5ed12a[_0x3248f5(0x1a4)]));},this[_0x75c740(0x15a)]),this[_0x75c740(0x1b0)]();}async['disconnect'](){const _0x1a49c4=a0_0x2eb4c7;if(this[_0x1a49c4(0x15b)]=!0x1,this[_0x1a49c4(0x1b8)]?.[_0x1a49c4(0x16a)](),this['heartbeatTimer'])clearInterval(this[_0x1a49c4(0x183)]);await this[_0x1a49c4(0x18b)](_0x1a49c4(0x1c8))['catch'](()=>{}),this[_0x1a49c4(0x1af)](_0x1a49c4(0x1bb));}async[a0_0x2eb4c7(0x184)](_0x244f70,_0x4bde7a,_0x12f0ff=a0_0x2eb4c7(0x15e)){const _0x2b7350=a0_0x2eb4c7;return Y({'alias':_0x244f70,'fromAlias':this[_0x2b7350(0x18f)]},{'log':_0x5d23f1=>console[_0x2b7350(0x1af)](_0x5d23f1),'send':()=>this['call']('send_task',{'alias':_0x244f70,'task':_0x4bde7a,'priority':_0x12f0ff,'from_session':this[_0x2b7350(0x18f)]})});}async[a0_0x2eb4c7(0x1a4)](_0x16b8a9,_0x1efd9d){const _0x1022df=a0_0x2eb4c7;return this['call'](_0x1022df(0x18c),{'alias':_0x16b8a9,'message':_0x1efd9d,'from_session':this[_0x1022df(0x18f)]});}async['reply'](_0x2bbd0e,_0x16b725,_0x41a68b='completed'){const _0x6a38dc=a0_0x2eb4c7;return this[_0x6a38dc(0x19b)]('send_reply',{'in_reply_to':_0x2bbd0e,'text':_0x16b725,'status':_0x41a68b});}async[a0_0x2eb4c7(0x18b)](_0x1ee112,_0x45f143){const _0xd95a9c=a0_0x2eb4c7;return this[_0xd95a9c(0x19b)](_0xd95a9c(0x1c7),{'resume_id':this[_0xd95a9c(0x192)],'alias':this[_0xd95a9c(0x18f)],'status':_0x1ee112,'server':a0_0x116f3d(),'hostname':a0_0x116f3d(),'agent':this[_0xd95a9c(0x170)],'project_dir':process['cwd'](),..._0x45f143});}async[a0_0x2eb4c7(0x176)](){const _0x58b162=a0_0x2eb4c7;return this['call'](_0x58b162(0x17a),{});}async[a0_0x2eb4c7(0x1b5)](_0x2e1e05,_0x3fee2f){const _0x29ccc1=a0_0x2eb4c7;return this['call'](_0x29ccc1(0x1b5),{'message':_0x2e1e05,'filter_server':_0x3fee2f?.[_0x29ccc1(0x1ab)],'filter_status':_0x3fee2f?.['status']});}async['connectSSE'](){const _0xd6d71a=a0_0x2eb4c7;let _0x57f55a=encodeURIComponent(this[_0xd6d71a(0x18f)]),_0x598f34=this[_0xd6d71a(0x157)]+_0xd6d71a(0x1aa)+_0x57f55a,_0x48af3a=this[_0xd6d71a(0x160)];while(this[_0xd6d71a(0x15b)]){try{this[_0xd6d71a(0x1b8)]=new AbortController();let _0x453475={'Accept':'text/event-stream'};if(this[_0xd6d71a(0x1b1)])_0x453475[_0xd6d71a(0x190)]=_0xd6d71a(0x166)+this['token'];let _0x3c00d1=await fetch(_0x598f34,{'headers':_0x453475,'signal':this[_0xd6d71a(0x1b8)][_0xd6d71a(0x162)]});if(!_0x3c00d1['ok']||!_0x3c00d1[_0xd6d71a(0x195)]){this[_0xd6d71a(0x1af)]('SSE\x20failed:\x20'+_0x3c00d1[_0xd6d71a(0x18b)]),await this[_0xd6d71a(0x198)](_0x48af3a),_0x48af3a=Math[_0xd6d71a(0x1a5)](_0x48af3a*1.5,0xea60);continue;}_0x48af3a=this[_0xd6d71a(0x160)];let _0x535dda=_0x3c00d1[_0xd6d71a(0x195)][_0xd6d71a(0x164)](),_0x479def=new TextDecoder(),_0x1f411c='';while(this[_0xd6d71a(0x15b)]){let {done:_0x22a15c,value:_0x50ba6a}=await _0x535dda['read']();if(_0x22a15c)break;_0x1f411c+=_0x479def[_0xd6d71a(0x152)](_0x50ba6a,{'stream':!0x0});let _0x387bec=_0x1f411c['split']('\x0a');_0x1f411c=_0x387bec[_0xd6d71a(0x19a)]()||'';for(let _0x3f929a of _0x387bec){if(!_0x3f929a['startsWith'](_0xd6d71a(0x169)))continue;try{let _0x4a659b=JSON['parse'](_0x3f929a[_0xd6d71a(0x16c)](0x6));if(_0x4a659b[_0xd6d71a(0x1b3)]===_0xd6d71a(0x175)){this['log'](_0xd6d71a(0x181)),this['emit']('connected');continue;}if(_0x4a659b[_0xd6d71a(0x1b3)]==='new_task'||_0x4a659b[_0xd6d71a(0x1b3)]===_0xd6d71a(0x172)||_0x4a659b[_0xd6d71a(0x1b3)]==='broadcast')await this[_0xd6d71a(0x1a1)]();}catch{}}}}catch(_0xeaad65){if(_0xeaad65[_0xd6d71a(0x196)]===_0xd6d71a(0x182))break;this[_0xd6d71a(0x189)](_0xd6d71a(0x1c2),_0xeaad65),this[_0xd6d71a(0x1af)](_0xd6d71a(0x1b2)+_0xeaad65[_0xd6d71a(0x1a4)]);}if(this[_0xd6d71a(0x15b)])this[_0xd6d71a(0x189)](_0xd6d71a(0x1bb)),this[_0xd6d71a(0x1af)](_0xd6d71a(0x19e)+_0x48af3a/0x3e8+_0xd6d71a(0x15c)),await this[_0xd6d71a(0x198)](_0x48af3a),_0x48af3a=Math['min'](_0x48af3a*1.5,0xea60);}}async[a0_0x2eb4c7(0x1a1)](){const _0x5df912=a0_0x2eb4c7;try{let _0x539981=(await this['call'](_0x5df912(0x18d),{'alias':this['alias'],'limit':0xa}))?.[_0x5df912(0x151)]||[];for(let _0x11c09b of _0x539981)await this[_0x5df912(0x19b)](_0x5df912(0x1a3),{'alias':this[_0x5df912(0x18f)],'message_id':_0x11c09b['id']}),this[_0x5df912(0x1af)]('←\x20'+_0x11c09b[_0x5df912(0x159)]+':\x20'+_0x11c09b[_0x5df912(0x1ad)][_0x5df912(0x16c)](0x0,0x3c)),this['emit'](_0x5df912(0x177),_0x11c09b),this[_0x5df912(0x189)](_0x5df912(0x1a4),_0x11c09b);}catch(_0x377930){this[_0x5df912(0x1af)](_0x5df912(0x1ba)+_0x377930['message']);}}[a0_0x2eb4c7(0x198)](_0x20c37b){return new Promise(_0x5d904a=>setTimeout(_0x5d904a,_0x20c37b));}}var F=$;export{F as default,$ as CommHub};function a0_0x141b(){const _0x15e4db=['idle','data:\x20','abort','9105qSptjZ','slice','task.replied','stringify','POST','agent','network_id','new_message','844IIPyPo','connect','connected','getAllStatus','task','replace','[commhub:task]\x20','get_all_status','send_failed','not_tracked','6122943UPBDHM','lifecycle_tracking','parent_task_id','toTimeString','SSE\x20connected','AbortError','heartbeatTimer','send','string','unknown\x20error','sending','2272372jhIEpN','emit','\x20duration_ms=','status','send_message','get_inbox','missing_task_id','alias','Authorization','tools/call','resumeId','duration_ms','\x20transport=','body','name','networkId','sleep','parse','pop','call','heartbeat\x20failed:\x20','1667007ZjsXqE','SSE\x20reconnecting\x20in\x20','transport','CommHub\x20rejected\x20task','processInbox','send_rejected','ack_inbox','message','min','568034xfbufb','application/json','56OlQzba','toString','/events/','server','<pending>','content','8TOCQzj','log','connectSSE','token','SSE\x20error:\x20','type','text','broadcast','\x20task_id=','error_message','sseAbort','task.ack','inbox\x20error:\x20','disconnected','task.send.delivered','delivered','catch','<unknown>','<missing>','parentTaskId','error','error_code','\x20network_id=','mcp_http','fromAlias','report_status','offline','\x20parent_task_id=','lifecycleTracking','messages','decode','json','to_alias','[REDACTED]','506712yDBSDg','url','match','from_session','heartbeatInterval','running','s...','/mcp','normal','failed','reconnectDelay','13747980tHJtvq','signal','autoConnect','getReader','sdk','Bearer\x20','now'];a0_0x141b=function(){return _0x15e4db;};return a0_0x141b();}