@sleep2agi/agent-network 2.3.0-preview.62 → 2.3.0-preview.63
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.
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a0_0x5bb32a=a0_0x17d4;function a0_0x576f(){const _0x5254d5=['send_rejected','emit','reconnectDelay','1397998NbVLNq','offline','sdk','connectSSE','missing_task_id','network_id','idle','content','heartbeatTimer','unknown\x20error','[REDACTED]','string','task.expired','alias','[commhub:task]\x20','\x20error=','SSE\x20error:\x20','error','lifecycleTracking','connected','result','912762zkxnOZ','replace','sdk-','getAllStatus','registered','new_task','\x20parent_task_id=','1612384ibyRro','status','completed','fromAlias','running','not_tracked','now','60vhEOQn','type','sleep','Bearer\x20','json','task.ack','tools/call','task.started','token','task','name','reply','startsWith','resumeId','message_id','disconnected','\x20network_id=','toString','from_alias','get_all_status','text','log','<pending>','send_reply','slice','send_failed','\x20task_id=','abort','task.replied','connect','min','transport','server','3156213STOamD','pop','processInbox','\x20transport=','2.0','task.send.delivered','catch','text/event-stream','disconnect','failed','broadcast','decode','31841824URenuB','1116680JbcYgu','sseAbort','SSE\x20connected','to_alias','getReader','ack_inbox','<unknown>','toAlias','send','duration_ms','Authorization','networkId','sending','CommHub\x20rejected\x20task','AbortError','\x20to=','split','delivered','heartbeatInterval','normal','<missing>','body','message','report_status','parse','parent_task_id','stringify','send_message','get_inbox','url','task_id','task.send.start','\x20from=','654057mwzyMp','call','read','inbox\x20error:\x20','/events/','agent'];a0_0x576f=function(){return _0x5254d5;};return a0_0x576f();}(function(_0x4f5807,_0x21416a){const _0x6dacea=a0_0x17d4,_0x5aebd7=_0x4f5807();while(!![]){try{const _0x34e784=parseInt(_0x6dacea(0x173))/0x1+-parseInt(_0x6dacea(0x152))/0x2+-parseInt(_0x6dacea(0x145))/0x3+-parseInt(_0x6dacea(0x11d))/0x4+-parseInt(_0x6dacea(0x124))/0x5*(parseInt(_0x6dacea(0x116))/0x6)+parseInt(_0x6dacea(0x17c))/0x7+parseInt(_0x6dacea(0x151))/0x8;if(_0x34e784===_0x21416a)break;else _0x5aebd7['push'](_0x5aebd7['shift']());}catch(_0x4db1af){_0x5aebd7['push'](_0x5aebd7['shift']());}}}(a0_0x576f,0xf2e98));import{EventEmitter as a0_0x54f089}from'events';import{hostname as a0_0x26deb8}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x272b7f,_0x3fb318)=>(_0x272b7f??_0x3fb318)[a0_0x5bb32a(0x117)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x5bb32a(0x13c)](0x0,0xf0);function N(_0x1a8131){const _0x10cbd6=a0_0x5bb32a;return(_0x1a8131 instanceof Error?_0x1a8131['message']:String(_0x1a8131??_0x10cbd6(0x10a)))[_0x10cbd6(0x117)](K,_0x10cbd6(0x10b))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x10cbd6(0x13c)](0x0,0xf0);}function O(_0x7f0df8,_0x3b14e7=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5bb32a(0x128)){const _0xb22a50=a0_0x5bb32a;if(_0x3b14e7)return JSON[_0xb22a50(0x16c)](_0x7f0df8);let _0x4ba0cc=L(_0x7f0df8[_0xb22a50(0x16b)],_0xb22a50(0x166)),_0x15bc99=L(_0x7f0df8[_0xb22a50(0x170)],_0xb22a50(0x13a)),_0x52e6b1=_0x7f0df8['error_code']?_0xb22a50(0x110)+_0x7f0df8['error_code']+':'+(_0x7f0df8['error_message']??''):'';return _0xb22a50(0x10f)+_0x7f0df8[_0xb22a50(0x11e)]+_0xb22a50(0x172)+L(_0x7f0df8[_0xb22a50(0x136)],'<unknown>')+_0xb22a50(0x161)+L(_0x7f0df8[_0xb22a50(0x155)],'<unknown>')+_0xb22a50(0x13e)+_0x15bc99+_0xb22a50(0x11c)+_0x4ba0cc+_0xb22a50(0x134)+L(_0x7f0df8[_0xb22a50(0x106)],_0xb22a50(0x158))+_0xb22a50(0x148)+_0x7f0df8[_0xb22a50(0x143)]+'\x20duration_ms='+_0x7f0df8[_0xb22a50(0x15b)]+'\x20lifecycle='+_0x7f0df8['lifecycle_tracking']+_0x52e6b1;}function U(_0x23d52c){const _0x1b89f2=a0_0x5bb32a;return{'event':{'sending':_0x1b89f2(0x171),'delivered':_0x1b89f2(0x14a),'failed':'task.send.failed','acked':_0x1b89f2(0x129),'started':_0x1b89f2(0x12b),'replied':_0x1b89f2(0x140),'expired':_0x1b89f2(0x10d)}[_0x23d52c['status']],..._0x23d52c};}function j(_0x12847c){const _0x5504c1=a0_0x5bb32a;let _0x170c53=_0x12847c?.['task_id']||_0x12847c?.[_0x5504c1(0x132)]||_0x12847c?.['id'];if(_0x170c53)return String(_0x170c53);let _0x506ec1=_0x12847c?.[_0x5504c1(0x108)]?.[0x0]?.[_0x5504c1(0x138)];if(typeof _0x506ec1!==_0x5504c1(0x10c))return null;try{let _0xe2bd8b=JSON['parse'](_0x506ec1);return _0xe2bd8b?.[_0x5504c1(0x170)]||_0xe2bd8b?.['message_id']||_0xe2bd8b?.['id']||null;}catch{return null;}}function a0_0x17d4(_0x16ef4b,_0x63810b){_0x16ef4b=_0x16ef4b-0x105;const _0x576fd5=a0_0x576f();let _0x17d462=_0x576fd5[_0x16ef4b];return _0x17d462;}async function X(_0x69c529,_0x567e74){const _0x20d575=a0_0x5bb32a;let _0x55942e=_0x567e74['now']??Date[_0x20d575(0x123)],_0x21dd2f=_0x55942e(),_0x2a328e=(_0x205712,_0x13857f,_0x32315d,_0x480595)=>{const _0x23d298=_0x20d575;_0x567e74['log'](O(U({'from_alias':_0x69c529[_0x23d298(0x120)],'to_alias':_0x69c529[_0x23d298(0x159)],'task_id':_0x13857f,'parent_task_id':_0x69c529['parentTaskId'],'network_id':_0x69c529[_0x23d298(0x15d)],'transport':_0x69c529['transport'],'status':_0x205712,'duration_ms':_0x55942e()-_0x21dd2f,'lifecycle_tracking':_0x69c529[_0x23d298(0x113)],..._0x32315d!==void 0x0?{'error_code':_0x480595||_0x23d298(0x13d),'error_message':N(_0x32315d)}:{}})));};_0x2a328e(_0x20d575(0x15e),null);try{let _0x14d5d7=await _0x567e74[_0x20d575(0x15a)](),_0x3a95ac=j(_0x14d5d7);if(_0x3a95ac)_0x2a328e(_0x20d575(0x163),_0x3a95ac);else{if(_0x14d5d7?.['ok']===!0x1||_0x14d5d7?.[_0x20d575(0x112)])_0x2a328e(_0x20d575(0x14e),_0x3a95ac,_0x14d5d7?.[_0x20d575(0x112)]||_0x20d575(0x15f),_0x20d575(0x179));else _0x2a328e(_0x20d575(0x14e),null,'CommHub\x20response\x20omitted\x20task_id',_0x20d575(0x105));}return _0x14d5d7;}catch(_0x3d86a4){throw _0x2a328e('failed',null,_0x3d86a4,_0x20d575(0x13d)),_0x3d86a4;}}async function Y(_0x216b74,_0x55ddc4){const _0x1653de=a0_0x5bb32a;return X({'fromAlias':_0x216b74[_0x1653de(0x120)],'toAlias':_0x216b74[_0x1653de(0x10e)],'parentTaskId':_0x216b74['parentTaskId']||null,'networkId':_0x216b74[_0x1653de(0x15d)]||null,'transport':'mcp_http','lifecycleTracking':_0x1653de(0x122)},_0x55ddc4);}class $ extends a0_0x54f089{[a0_0x5bb32a(0x16f)];[a0_0x5bb32a(0x10e)];[a0_0x5bb32a(0x12c)];[a0_0x5bb32a(0x178)];[a0_0x5bb32a(0x131)];[a0_0x5bb32a(0x164)];[a0_0x5bb32a(0x17b)];['heartbeatTimer'];[a0_0x5bb32a(0x153)];[a0_0x5bb32a(0x121)]=!0x1;constructor(_0x26bf74){const _0xee09d6=a0_0x5bb32a;super();if(this[_0xee09d6(0x16f)]=_0x26bf74[_0xee09d6(0x16f)][_0xee09d6(0x117)](/\/$/,''),this[_0xee09d6(0x10e)]=_0x26bf74[_0xee09d6(0x10e)],this['token']=_0x26bf74[_0xee09d6(0x12c)],this[_0xee09d6(0x178)]=_0x26bf74[_0xee09d6(0x178)]||_0xee09d6(0x17e),this[_0xee09d6(0x131)]=_0xee09d6(0x118)+_0x26bf74[_0xee09d6(0x10e)]+'-'+Date[_0xee09d6(0x123)]()[_0xee09d6(0x135)](0x24),this[_0xee09d6(0x164)]=_0x26bf74[_0xee09d6(0x164)]??0x2bf20,this[_0xee09d6(0x17b)]=_0x26bf74[_0xee09d6(0x17b)]??0xbb8,_0x26bf74['autoConnect']!==!0x1)this[_0xee09d6(0x141)]();}[a0_0x5bb32a(0x139)](_0x275f80){const _0x4ab468=a0_0x5bb32a;console[_0x4ab468(0x139)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+']\x20[commhub:'+this['alias']+']\x20'+_0x275f80);}async[a0_0x5bb32a(0x174)](_0x53c8c6,_0x5e5a73){const _0x3d30e6=a0_0x5bb32a;let _0x1f3570={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this[_0x3d30e6(0x12c)])_0x1f3570[_0x3d30e6(0x15c)]=_0x3d30e6(0x127)+this['token'];let _0x38bb26=await(await fetch(this[_0x3d30e6(0x16f)]+'/mcp',{'method':'POST','headers':_0x1f3570,'body':JSON[_0x3d30e6(0x16c)]({'jsonrpc':_0x3d30e6(0x149),'id':Date[_0x3d30e6(0x123)](),'method':_0x3d30e6(0x12a),'params':{'name':_0x53c8c6,'arguments':_0x5e5a73}})}))[_0x3d30e6(0x138)](),_0x17744c=_0x38bb26['match'](/data: (.+)/),_0x5cb39f=_0x17744c?JSON[_0x3d30e6(0x16a)](_0x17744c[0x1]):JSON['parse'](_0x38bb26),_0x1cb2c3=_0x5cb39f?.[_0x3d30e6(0x115)]?.[_0x3d30e6(0x108)]?.[0x0]?.[_0x3d30e6(0x138)];return _0x1cb2c3?JSON[_0x3d30e6(0x16a)](_0x1cb2c3):_0x5cb39f;}async['connect'](){const _0x4488d6=a0_0x5bb32a;if(this[_0x4488d6(0x121)])return;this['running']=!0x0,await this[_0x4488d6(0x11e)](_0x4488d6(0x107)),this[_0x4488d6(0x139)](_0x4488d6(0x11a)),this[_0x4488d6(0x109)]=setInterval(()=>{const _0x2a9acc=_0x4488d6;this[_0x2a9acc(0x11e)](_0x2a9acc(0x107))[_0x2a9acc(0x14b)](_0x11a5a8=>this['log']('heartbeat\x20failed:\x20'+_0x11a5a8[_0x2a9acc(0x168)]));},this['heartbeatInterval']),this[_0x4488d6(0x17f)]();}async[a0_0x5bb32a(0x14d)](){const _0x488c11=a0_0x5bb32a;if(this[_0x488c11(0x121)]=!0x1,this['sseAbort']?.[_0x488c11(0x13f)](),this[_0x488c11(0x109)])clearInterval(this[_0x488c11(0x109)]);await this[_0x488c11(0x11e)](_0x488c11(0x17d))[_0x488c11(0x14b)](()=>{}),this[_0x488c11(0x139)](_0x488c11(0x133));}async[a0_0x5bb32a(0x15a)](_0x5c3688,_0xfa7926,_0x4e0e29=a0_0x5bb32a(0x165)){const _0x48a244=a0_0x5bb32a;return Y({'alias':_0x5c3688,'fromAlias':this[_0x48a244(0x10e)]},{'log':_0x1f9c2a=>console['log'](_0x1f9c2a),'send':()=>this[_0x48a244(0x174)]('send_task',{'alias':_0x5c3688,'task':_0xfa7926,'priority':_0x4e0e29,'from_session':this[_0x48a244(0x10e)]})});}async[a0_0x5bb32a(0x168)](_0x1145b7,_0x345324){const _0x4c1dd9=a0_0x5bb32a;return this[_0x4c1dd9(0x174)](_0x4c1dd9(0x16d),{'alias':_0x1145b7,'message':_0x345324,'from_session':this[_0x4c1dd9(0x10e)]});}async[a0_0x5bb32a(0x12f)](_0x5f2a0c,_0xa1ddc,_0x288c99=a0_0x5bb32a(0x11f)){const _0x14e868=a0_0x5bb32a;return this[_0x14e868(0x174)](_0x14e868(0x13b),{'in_reply_to':_0x5f2a0c,'text':_0xa1ddc,'status':_0x288c99});}async[a0_0x5bb32a(0x11e)](_0x4ce402,_0x602261){const _0x3614c5=a0_0x5bb32a;return this['call'](_0x3614c5(0x169),{'resume_id':this['resumeId'],'alias':this[_0x3614c5(0x10e)],'status':_0x4ce402,'server':a0_0x26deb8(),'hostname':a0_0x26deb8(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x602261});}async[a0_0x5bb32a(0x119)](){const _0x374a78=a0_0x5bb32a;return this['call'](_0x374a78(0x137),{});}async[a0_0x5bb32a(0x14f)](_0x43f942,_0x195a47){const _0x3f86f5=a0_0x5bb32a;return this[_0x3f86f5(0x174)](_0x3f86f5(0x14f),{'message':_0x43f942,'filter_server':_0x195a47?.[_0x3f86f5(0x144)],'filter_status':_0x195a47?.['status']});}async[a0_0x5bb32a(0x17f)](){const _0x144d6f=a0_0x5bb32a;let _0x4f58f8=encodeURIComponent(this[_0x144d6f(0x10e)]),_0x5e7f60=this[_0x144d6f(0x16f)]+_0x144d6f(0x177)+_0x4f58f8,_0x5400af=this['reconnectDelay'];while(this[_0x144d6f(0x121)]){try{this[_0x144d6f(0x153)]=new AbortController();let _0x252802={'Accept':_0x144d6f(0x14c)};if(this['token'])_0x252802[_0x144d6f(0x15c)]=_0x144d6f(0x127)+this[_0x144d6f(0x12c)];let _0x4ec7d0=await fetch(_0x5e7f60,{'headers':_0x252802,'signal':this[_0x144d6f(0x153)]['signal']});if(!_0x4ec7d0['ok']||!_0x4ec7d0[_0x144d6f(0x167)]){this[_0x144d6f(0x139)]('SSE\x20failed:\x20'+_0x4ec7d0[_0x144d6f(0x11e)]),await this[_0x144d6f(0x126)](_0x5400af),_0x5400af=Math[_0x144d6f(0x142)](_0x5400af*1.5,0xea60);continue;}_0x5400af=this['reconnectDelay'];let _0x18d93e=_0x4ec7d0[_0x144d6f(0x167)][_0x144d6f(0x156)](),_0x2e16c7=new TextDecoder(),_0x3c41ef='';while(this['running']){let {done:_0x8ea213,value:_0x4d627b}=await _0x18d93e[_0x144d6f(0x175)]();if(_0x8ea213)break;_0x3c41ef+=_0x2e16c7[_0x144d6f(0x150)](_0x4d627b,{'stream':!0x0});let _0x5b198e=_0x3c41ef[_0x144d6f(0x162)]('\x0a');_0x3c41ef=_0x5b198e[_0x144d6f(0x146)]()||'';for(let _0xf1edd8 of _0x5b198e){if(!_0xf1edd8[_0x144d6f(0x130)]('data:\x20'))continue;try{let _0x5dd0be=JSON['parse'](_0xf1edd8[_0x144d6f(0x13c)](0x6));if(_0x5dd0be[_0x144d6f(0x125)]===_0x144d6f(0x114)){this[_0x144d6f(0x139)](_0x144d6f(0x154)),this[_0x144d6f(0x17a)](_0x144d6f(0x114));continue;}if(_0x5dd0be[_0x144d6f(0x125)]===_0x144d6f(0x11b)||_0x5dd0be['type']==='new_message'||_0x5dd0be[_0x144d6f(0x125)]==='broadcast')await this[_0x144d6f(0x147)]();}catch{}}}}catch(_0x196475){if(_0x196475[_0x144d6f(0x12e)]===_0x144d6f(0x160))break;this[_0x144d6f(0x17a)]('error',_0x196475),this['log'](_0x144d6f(0x111)+_0x196475[_0x144d6f(0x168)]);}if(this[_0x144d6f(0x121)])this[_0x144d6f(0x17a)](_0x144d6f(0x133)),this[_0x144d6f(0x139)]('SSE\x20reconnecting\x20in\x20'+_0x5400af/0x3e8+'s...'),await this[_0x144d6f(0x126)](_0x5400af),_0x5400af=Math['min'](_0x5400af*1.5,0xea60);}}async[a0_0x5bb32a(0x147)](){const _0x3608fe=a0_0x5bb32a;try{let _0x443b19=(await this[_0x3608fe(0x174)](_0x3608fe(0x16e),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x3aab68 of _0x443b19)await this[_0x3608fe(0x174)](_0x3608fe(0x157),{'alias':this[_0x3608fe(0x10e)],'message_id':_0x3aab68['id']}),this[_0x3608fe(0x139)]('←\x20'+_0x3aab68['from_session']+':\x20'+_0x3aab68[_0x3608fe(0x108)][_0x3608fe(0x13c)](0x0,0x3c)),this[_0x3608fe(0x17a)](_0x3608fe(0x12d),_0x3aab68),this['emit'](_0x3608fe(0x168),_0x3aab68);}catch(_0x5dbaec){this[_0x3608fe(0x139)](_0x3608fe(0x176)+_0x5dbaec[_0x3608fe(0x168)]);}}[a0_0x5bb32a(0x126)](_0x494e83){return new Promise(_0x3c2cba=>setTimeout(_0x3c2cba,_0x494e83));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x2cb9f1=a0_0x1c32;function a0_0x1c32(_0x1b36dd,_0xe5e0b8){_0x1b36dd=_0x1b36dd-0x108;const _0x57badb=a0_0x57ba();let _0x1c3207=_0x57badb[_0x1b36dd];return _0x1c3207;}(function(_0x49d899,_0x3240aa){const _0x3dbdd1=a0_0x1c32,_0x58b1e6=_0x49d899();while(!![]){try{const _0x537e96=parseInt(_0x3dbdd1(0x147))/0x1+-parseInt(_0x3dbdd1(0x12e))/0x2*(parseInt(_0x3dbdd1(0x152))/0x3)+parseInt(_0x3dbdd1(0x136))/0x4*(-parseInt(_0x3dbdd1(0x15a))/0x5)+-parseInt(_0x3dbdd1(0x14c))/0x6*(parseInt(_0x3dbdd1(0x117))/0x7)+parseInt(_0x3dbdd1(0x132))/0x8+-parseInt(_0x3dbdd1(0x110))/0x9+parseInt(_0x3dbdd1(0x12b))/0xa*(parseInt(_0x3dbdd1(0x14b))/0xb);if(_0x537e96===_0x3240aa)break;else _0x58b1e6['push'](_0x58b1e6['shift']());}catch(_0x5d097e){_0x58b1e6['push'](_0x58b1e6['shift']());}}}(a0_0x57ba,0xdbdca));import{EventEmitter as a0_0x3fa7de}from'events';import{hostname as a0_0x49a45c}from'os';function a0_0x57ba(){const _0x437cf0=['error','get_inbox','send_message','9008440gwcTKH','send_reply','new_task','\x20parent_task_id=','312204ZzpZER','application/json','task.started','type','string','unknown\x20error','SSE\x20reconnecting\x20in\x20','send_failed','task.ack','catch','message','abort','disconnected','url','SSE\x20failed:\x20','send','cwd','1231272ftytZz','body','text/event-stream','Bearer\x20','22uOmCQt','2023878VUHOrJ','lifecycleTracking','sseAbort','failed','token','error_message','843cAgUuI','transport','processInbox','signal','sdk','tools/call','running','call','85NraxWA','now','messages','ack_inbox','alias','connectSSE','toTimeString','AbortError','<unknown>','parentTaskId','sending','delivered','inbox\x20error:\x20','parent_task_id','log','registered','broadcast','sleep','get_all_status',']\x20[commhub:','2.0','data:\x20','<pending>','missing_task_id','offline','\x20task_id=','\x20from=','text','to_alias','server','\x20transport=','stringify','read','\x20to=','message_id','heartbeat\x20failed:\x20','replace','from_alias','\x20network_id=','emit','fromAlias','SSE\x20connected','networkId','getReader','decode','toString','resumeId','task.send.failed','duration_ms','slice','heartbeatInterval','split','task.replied','Authorization','idle','7803639mbthKC','content','<missing>','\x20duration_ms=','reconnectDelay','agent','connect','35pTidTW','task.expired','match','status','autoConnect','CommHub\x20response\x20omitted\x20task_id','min','[commhub:task]\x20','not_tracked','mcp_http','new_message','task_id','parse','connected','SSE\x20error:\x20','result','report_status','network_id','getAllStatus','\x20lifecycle=','19736560BsymmS','heartbeatTimer','s...','10844pDSfMo'];a0_0x57ba=function(){return _0x437cf0;};return a0_0x57ba();}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x5eda4f,_0x5c49d5)=>(_0x5eda4f??_0x5c49d5)[a0_0x2cb9f1(0x17e)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x2cb9f1(0x10a)](0x0,0xf0);function N(_0x15e04d){const _0x479365=a0_0x2cb9f1;return(_0x15e04d instanceof Error?_0x15e04d[_0x479365(0x140)]:String(_0x15e04d??_0x479365(0x13b)))['replace'](K,'[REDACTED]')[_0x479365(0x17e)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x479365(0x10a)](0x0,0xf0);}function O(_0x5505ed,_0x74f127=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x591f82=a0_0x2cb9f1;if(_0x74f127)return JSON[_0x591f82(0x179)](_0x5505ed);let _0x5e01fc=L(_0x5505ed[_0x591f82(0x167)],_0x591f82(0x112)),_0x38a2d5=L(_0x5505ed[_0x591f82(0x122)],_0x591f82(0x170)),_0x283907=_0x5505ed['error_code']?'\x20error='+_0x5505ed['error_code']+':'+(_0x5505ed[_0x591f82(0x151)]??''):'';return _0x591f82(0x11e)+_0x5505ed[_0x591f82(0x11a)]+_0x591f82(0x174)+L(_0x5505ed[_0x591f82(0x17f)],_0x591f82(0x162))+_0x591f82(0x17b)+L(_0x5505ed[_0x591f82(0x176)],_0x591f82(0x162))+_0x591f82(0x173)+_0x38a2d5+_0x591f82(0x135)+_0x5e01fc+_0x591f82(0x180)+L(_0x5505ed[_0x591f82(0x128)],'<unknown>')+_0x591f82(0x178)+_0x5505ed[_0x591f82(0x153)]+_0x591f82(0x113)+_0x5505ed[_0x591f82(0x109)]+_0x591f82(0x12a)+_0x5505ed['lifecycle_tracking']+_0x283907;}function U(_0x10d5f2){const _0x16599d=a0_0x2cb9f1;return{'event':{'sending':'task.send.start','delivered':'task.send.delivered','failed':_0x16599d(0x108),'acked':_0x16599d(0x13e),'started':_0x16599d(0x138),'replied':_0x16599d(0x10d),'expired':_0x16599d(0x118)}[_0x10d5f2[_0x16599d(0x11a)]],..._0x10d5f2};}function j(_0x2a3030){const _0x465420=a0_0x2cb9f1;let _0x15e555=_0x2a3030?.[_0x465420(0x122)]||_0x2a3030?.[_0x465420(0x17c)]||_0x2a3030?.['id'];if(_0x15e555)return String(_0x15e555);let _0x4618e5=_0x2a3030?.[_0x465420(0x111)]?.[0x0]?.[_0x465420(0x175)];if(typeof _0x4618e5!==_0x465420(0x13a))return null;try{let _0x34976e=JSON['parse'](_0x4618e5);return _0x34976e?.['task_id']||_0x34976e?.[_0x465420(0x17c)]||_0x34976e?.['id']||null;}catch{return null;}}async function X(_0x49b9ac,_0x3ac7bd){const _0x2bed0d=a0_0x2cb9f1;let _0x39a2e8=_0x3ac7bd[_0x2bed0d(0x15b)]??Date[_0x2bed0d(0x15b)],_0x14d697=_0x39a2e8(),_0x103c2c=(_0x1400ab,_0x33bced,_0x5c8fea,_0x97c24)=>{const _0x551eb2=_0x2bed0d;_0x3ac7bd[_0x551eb2(0x168)](O(U({'from_alias':_0x49b9ac[_0x551eb2(0x182)],'to_alias':_0x49b9ac['toAlias'],'task_id':_0x33bced,'parent_task_id':_0x49b9ac['parentTaskId'],'network_id':_0x49b9ac['networkId'],'transport':_0x49b9ac[_0x551eb2(0x153)],'status':_0x1400ab,'duration_ms':_0x39a2e8()-_0x14d697,'lifecycle_tracking':_0x49b9ac[_0x551eb2(0x14d)],..._0x5c8fea!==void 0x0?{'error_code':_0x97c24||'send_failed','error_message':N(_0x5c8fea)}:{}})));};_0x103c2c(_0x2bed0d(0x164),null);try{let _0x43e14f=await _0x3ac7bd[_0x2bed0d(0x145)](),_0x44e86d=j(_0x43e14f);if(_0x44e86d)_0x103c2c(_0x2bed0d(0x165),_0x44e86d);else{if(_0x43e14f?.['ok']===!0x1||_0x43e14f?.[_0x2bed0d(0x12f)])_0x103c2c(_0x2bed0d(0x14f),_0x44e86d,_0x43e14f?.['error']||'CommHub\x20rejected\x20task','send_rejected');else _0x103c2c(_0x2bed0d(0x14f),null,_0x2bed0d(0x11c),_0x2bed0d(0x171));}return _0x43e14f;}catch(_0x4503f3){throw _0x103c2c('failed',null,_0x4503f3,_0x2bed0d(0x13d)),_0x4503f3;}}async function Y(_0x4ea101,_0x1285e8){const _0x44e6c8=a0_0x2cb9f1;return X({'fromAlias':_0x4ea101[_0x44e6c8(0x182)],'toAlias':_0x4ea101['alias'],'parentTaskId':_0x4ea101[_0x44e6c8(0x163)]||null,'networkId':_0x4ea101[_0x44e6c8(0x184)]||null,'transport':_0x44e6c8(0x120),'lifecycleTracking':_0x44e6c8(0x11f)},_0x1285e8);}class $ extends a0_0x3fa7de{[a0_0x2cb9f1(0x143)];[a0_0x2cb9f1(0x15e)];[a0_0x2cb9f1(0x150)];[a0_0x2cb9f1(0x115)];[a0_0x2cb9f1(0x188)];[a0_0x2cb9f1(0x10b)];[a0_0x2cb9f1(0x114)];[a0_0x2cb9f1(0x12c)];[a0_0x2cb9f1(0x14e)];[a0_0x2cb9f1(0x158)]=!0x1;constructor(_0x75fae0){const _0x3b37b2=a0_0x2cb9f1;super();if(this['url']=_0x75fae0['url']['replace'](/\/$/,''),this['alias']=_0x75fae0['alias'],this[_0x3b37b2(0x150)]=_0x75fae0[_0x3b37b2(0x150)],this[_0x3b37b2(0x115)]=_0x75fae0[_0x3b37b2(0x115)]||_0x3b37b2(0x156),this[_0x3b37b2(0x188)]='sdk-'+_0x75fae0[_0x3b37b2(0x15e)]+'-'+Date[_0x3b37b2(0x15b)]()[_0x3b37b2(0x187)](0x24),this[_0x3b37b2(0x10b)]=_0x75fae0['heartbeatInterval']??0x2bf20,this['reconnectDelay']=_0x75fae0[_0x3b37b2(0x114)]??0xbb8,_0x75fae0[_0x3b37b2(0x11b)]!==!0x1)this[_0x3b37b2(0x116)]();}[a0_0x2cb9f1(0x168)](_0x1d99c6){const _0x1cf3f6=a0_0x2cb9f1;console[_0x1cf3f6(0x168)]('['+new Date()[_0x1cf3f6(0x160)]()[_0x1cf3f6(0x10a)](0x0,0x8)+_0x1cf3f6(0x16d)+this[_0x1cf3f6(0x15e)]+']\x20'+_0x1d99c6);}async[a0_0x2cb9f1(0x159)](_0x4b17aa,_0x15c644){const _0x1c1932=a0_0x2cb9f1;let _0x27722b={'Content-Type':_0x1c1932(0x137),'Accept':'application/json,\x20text/event-stream'};if(this[_0x1c1932(0x150)])_0x27722b[_0x1c1932(0x10e)]=_0x1c1932(0x14a)+this[_0x1c1932(0x150)];let _0x2eac6c=await(await fetch(this[_0x1c1932(0x143)]+'/mcp',{'method':'POST','headers':_0x27722b,'body':JSON[_0x1c1932(0x179)]({'jsonrpc':_0x1c1932(0x16e),'id':Date['now'](),'method':_0x1c1932(0x157),'params':{'name':_0x4b17aa,'arguments':_0x15c644}})}))[_0x1c1932(0x175)](),_0x54f3f9=_0x2eac6c[_0x1c1932(0x119)](/data: (.+)/),_0x2dd623=_0x54f3f9?JSON[_0x1c1932(0x123)](_0x54f3f9[0x1]):JSON['parse'](_0x2eac6c),_0x450685=_0x2dd623?.[_0x1c1932(0x126)]?.[_0x1c1932(0x111)]?.[0x0]?.[_0x1c1932(0x175)];return _0x450685?JSON['parse'](_0x450685):_0x2dd623;}async[a0_0x2cb9f1(0x116)](){const _0x3af075=a0_0x2cb9f1;if(this[_0x3af075(0x158)])return;this['running']=!0x0,await this[_0x3af075(0x11a)](_0x3af075(0x10f)),this[_0x3af075(0x168)](_0x3af075(0x169)),this[_0x3af075(0x12c)]=setInterval(()=>{const _0x890aa1=_0x3af075;this[_0x890aa1(0x11a)](_0x890aa1(0x10f))['catch'](_0x351813=>this['log'](_0x890aa1(0x17d)+_0x351813[_0x890aa1(0x140)]));},this['heartbeatInterval']),this[_0x3af075(0x15f)]();}async['disconnect'](){const _0x5a37c9=a0_0x2cb9f1;if(this[_0x5a37c9(0x158)]=!0x1,this['sseAbort']?.[_0x5a37c9(0x141)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this['status'](_0x5a37c9(0x172))[_0x5a37c9(0x13f)](()=>{}),this['log'](_0x5a37c9(0x142));}async[a0_0x2cb9f1(0x145)](_0x210390,_0x7fcd5f,_0x3857b8='normal'){const _0x5ce353=a0_0x2cb9f1;return Y({'alias':_0x210390,'fromAlias':this[_0x5ce353(0x15e)]},{'log':_0x5b5c54=>console[_0x5ce353(0x168)](_0x5b5c54),'send':()=>this['call']('send_task',{'alias':_0x210390,'task':_0x7fcd5f,'priority':_0x3857b8,'from_session':this['alias']})});}async[a0_0x2cb9f1(0x140)](_0x53e510,_0x5471cb){const _0x21bd87=a0_0x2cb9f1;return this[_0x21bd87(0x159)](_0x21bd87(0x131),{'alias':_0x53e510,'message':_0x5471cb,'from_session':this['alias']});}async['reply'](_0xa96c3b,_0x2b5c42,_0x5c7c22='completed'){const _0x5ae1d2=a0_0x2cb9f1;return this['call'](_0x5ae1d2(0x133),{'in_reply_to':_0xa96c3b,'text':_0x2b5c42,'status':_0x5c7c22});}async[a0_0x2cb9f1(0x11a)](_0x14f725,_0x5f94b1){const _0x3fc28a=a0_0x2cb9f1;return this[_0x3fc28a(0x159)](_0x3fc28a(0x127),{'resume_id':this['resumeId'],'alias':this[_0x3fc28a(0x15e)],'status':_0x14f725,'server':a0_0x49a45c(),'hostname':a0_0x49a45c(),'agent':this[_0x3fc28a(0x115)],'project_dir':process[_0x3fc28a(0x146)](),..._0x5f94b1});}async[a0_0x2cb9f1(0x129)](){const _0x30e8ae=a0_0x2cb9f1;return this[_0x30e8ae(0x159)](_0x30e8ae(0x16c),{});}async[a0_0x2cb9f1(0x16a)](_0x1f8770,_0xfdd123){const _0x3f6cb8=a0_0x2cb9f1;return this[_0x3f6cb8(0x159)](_0x3f6cb8(0x16a),{'message':_0x1f8770,'filter_server':_0xfdd123?.[_0x3f6cb8(0x177)],'filter_status':_0xfdd123?.['status']});}async[a0_0x2cb9f1(0x15f)](){const _0x2bf6dd=a0_0x2cb9f1;let _0x8cc6eb=encodeURIComponent(this[_0x2bf6dd(0x15e)]),_0x4f9e90=this['url']+'/events/'+_0x8cc6eb,_0x46b56a=this[_0x2bf6dd(0x114)];while(this['running']){try{this['sseAbort']=new AbortController();let _0x2f2203={'Accept':_0x2bf6dd(0x149)};if(this[_0x2bf6dd(0x150)])_0x2f2203['Authorization']='Bearer\x20'+this[_0x2bf6dd(0x150)];let _0x3ed0da=await fetch(_0x4f9e90,{'headers':_0x2f2203,'signal':this['sseAbort'][_0x2bf6dd(0x155)]});if(!_0x3ed0da['ok']||!_0x3ed0da['body']){this['log'](_0x2bf6dd(0x144)+_0x3ed0da[_0x2bf6dd(0x11a)]),await this['sleep'](_0x46b56a),_0x46b56a=Math[_0x2bf6dd(0x11d)](_0x46b56a*1.5,0xea60);continue;}_0x46b56a=this['reconnectDelay'];let _0x134ecb=_0x3ed0da[_0x2bf6dd(0x148)][_0x2bf6dd(0x185)](),_0x2a131b=new TextDecoder(),_0x1cbf96='';while(this[_0x2bf6dd(0x158)]){let {done:_0x3dfca3,value:_0xf3ce63}=await _0x134ecb[_0x2bf6dd(0x17a)]();if(_0x3dfca3)break;_0x1cbf96+=_0x2a131b[_0x2bf6dd(0x186)](_0xf3ce63,{'stream':!0x0});let _0x56bfc0=_0x1cbf96[_0x2bf6dd(0x10c)]('\x0a');_0x1cbf96=_0x56bfc0['pop']()||'';for(let _0x375c79 of _0x56bfc0){if(!_0x375c79['startsWith'](_0x2bf6dd(0x16f)))continue;try{let _0x2692e1=JSON[_0x2bf6dd(0x123)](_0x375c79[_0x2bf6dd(0x10a)](0x6));if(_0x2692e1[_0x2bf6dd(0x139)]===_0x2bf6dd(0x124)){this['log'](_0x2bf6dd(0x183)),this[_0x2bf6dd(0x181)](_0x2bf6dd(0x124));continue;}if(_0x2692e1['type']===_0x2bf6dd(0x134)||_0x2692e1[_0x2bf6dd(0x139)]===_0x2bf6dd(0x121)||_0x2692e1[_0x2bf6dd(0x139)]==='broadcast')await this['processInbox']();}catch{}}}}catch(_0x270a20){if(_0x270a20['name']===_0x2bf6dd(0x161))break;this[_0x2bf6dd(0x181)](_0x2bf6dd(0x12f),_0x270a20),this[_0x2bf6dd(0x168)](_0x2bf6dd(0x125)+_0x270a20['message']);}if(this[_0x2bf6dd(0x158)])this[_0x2bf6dd(0x181)](_0x2bf6dd(0x142)),this[_0x2bf6dd(0x168)](_0x2bf6dd(0x13c)+_0x46b56a/0x3e8+_0x2bf6dd(0x12d)),await this[_0x2bf6dd(0x16b)](_0x46b56a),_0x46b56a=Math[_0x2bf6dd(0x11d)](_0x46b56a*1.5,0xea60);}}async[a0_0x2cb9f1(0x154)](){const _0x18fd5d=a0_0x2cb9f1;try{let _0x19747a=(await this[_0x18fd5d(0x159)](_0x18fd5d(0x130),{'alias':this['alias'],'limit':0xa}))?.[_0x18fd5d(0x15c)]||[];for(let _0x42ba22 of _0x19747a)await this[_0x18fd5d(0x159)](_0x18fd5d(0x15d),{'alias':this[_0x18fd5d(0x15e)],'message_id':_0x42ba22['id']}),this[_0x18fd5d(0x168)]('←\x20'+_0x42ba22['from_session']+':\x20'+_0x42ba22[_0x18fd5d(0x111)][_0x18fd5d(0x10a)](0x0,0x3c)),this[_0x18fd5d(0x181)]('task',_0x42ba22),this[_0x18fd5d(0x181)](_0x18fd5d(0x140),_0x42ba22);}catch(_0x998b9a){this[_0x18fd5d(0x168)](_0x18fd5d(0x166)+_0x998b9a[_0x18fd5d(0x140)]);}}[a0_0x2cb9f1(0x16b)](_0x5fb9cd){return new Promise(_0x49050e=>setTimeout(_0x49050e,_0x5fb9cd));}}var F=$;export{F as default,$ as CommHub};
|