@sleep2agi/agent-network 2.3.0-preview.267 → 2.3.0-preview.268
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_0x3628a8=a0_0x6382;(function(_0x294cf5,_0x1341c3){const _0x226192=a0_0x6382,_0x5d4c26=_0x294cf5();while(!![]){try{const _0x56f497=-parseInt(_0x226192(0x127))/0x1+-parseInt(_0x226192(0x12d))/0x2*(parseInt(_0x226192(0x139))/0x3)+parseInt(_0x226192(0x164))/0x4+-parseInt(_0x226192(0x173))/0x5*(-parseInt(_0x226192(0x158))/0x6)+parseInt(_0x226192(0x141))/0x7+-parseInt(_0x226192(0x12b))/0x8*(-parseInt(_0x226192(0x19d))/0x9)+parseInt(_0x226192(0x17f))/0xa*(-parseInt(_0x226192(0x13d))/0xb);if(_0x56f497===_0x1341c3)break;else _0x5d4c26['push'](_0x5d4c26['shift']());}catch(_0x2a5558){_0x5d4c26['push'](_0x5d4c26['shift']());}}}(a0_0xc728,0x1c141));import{EventEmitter as a0_0x150ff0}from'events';import{hostname as a0_0x4846f8}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x5a740d,_0x96f21c)=>(_0x5a740d??_0x96f21c)[a0_0x3628a8(0x167)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x481f9e){const _0x1725a3=a0_0x3628a8;return(_0x481f9e instanceof Error?_0x481f9e[_0x1725a3(0x142)]:String(_0x481f9e??_0x1725a3(0x19e)))[_0x1725a3(0x167)](K,'[REDACTED]')[_0x1725a3(0x167)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x1725a3(0x134)](0x0,0xf0);}function O(_0x130c16,_0xf6b5a1=process.env.ANET_TASK_TRACE_FORMAT===a0_0x3628a8(0x151)){const _0x1e77f7=a0_0x3628a8;if(_0xf6b5a1)return JSON[_0x1e77f7(0x181)](_0x130c16);let _0x50bfa6=L(_0x130c16['parent_task_id'],_0x1e77f7(0x1a0)),_0xadb608=L(_0x130c16['task_id'],_0x1e77f7(0x1a3)),_0xd66fad=_0x130c16['error_code']?_0x1e77f7(0x17d)+_0x130c16[_0x1e77f7(0x171)]+':'+(_0x130c16[_0x1e77f7(0x16f)]??''):'';return'[commhub:task]\x20'+_0x130c16[_0x1e77f7(0x18c)]+'\x20from='+L(_0x130c16['from_alias'],_0x1e77f7(0x16d))+_0x1e77f7(0x194)+L(_0x130c16[_0x1e77f7(0x13e)],'<unknown>')+_0x1e77f7(0x13a)+_0xadb608+_0x1e77f7(0x180)+_0x50bfa6+'\x20network_id='+L(_0x130c16[_0x1e77f7(0x196)],_0x1e77f7(0x16d))+_0x1e77f7(0x16a)+_0x130c16[_0x1e77f7(0x136)]+'\x20duration_ms='+_0x130c16[_0x1e77f7(0x138)]+_0x1e77f7(0x1a8)+_0x130c16[_0x1e77f7(0x13c)]+_0xd66fad;}function a0_0x6382(_0x3a4062,_0x413b17){_0x3a4062=_0x3a4062-0x127;const _0xc7285=a0_0xc728();let _0x63826=_0xc7285[_0x3a4062];return _0x63826;}function U(_0x39bafa){const _0x7552af=a0_0x3628a8;return{'event':{'sending':_0x7552af(0x14f),'delivered':'task.send.delivered','failed':_0x7552af(0x198),'acked':_0x7552af(0x168),'started':_0x7552af(0x163),'replied':_0x7552af(0x157),'expired':_0x7552af(0x177)}[_0x39bafa['status']],..._0x39bafa};}function j(_0x4caa10){const _0xf9df9f=a0_0x3628a8;let _0x280a50=_0x4caa10?.[_0xf9df9f(0x145)]||_0x4caa10?.[_0xf9df9f(0x129)]||_0x4caa10?.['id'];if(_0x280a50)return String(_0x280a50);let _0x414844=_0x4caa10?.['content']?.[0x0]?.['text'];if(typeof _0x414844!=='string')return null;try{let _0x1aa276=JSON[_0xf9df9f(0x147)](_0x414844);return _0x1aa276?.[_0xf9df9f(0x145)]||_0x1aa276?.['message_id']||_0x1aa276?.['id']||null;}catch{return null;}}async function X(_0x3ffd8a,_0x343894){const _0x2e6703=a0_0x3628a8;let _0x458927=_0x343894['now']??Date['now'],_0x3eea43=_0x458927(),_0x1c59a4=(_0x4b4fb6,_0x410c5a,_0x1b5f5e,_0xd6a61c)=>{const _0x2efff2=a0_0x6382;_0x343894[_0x2efff2(0x199)](O(U({'from_alias':_0x3ffd8a[_0x2efff2(0x1a1)],'to_alias':_0x3ffd8a[_0x2efff2(0x148)],'task_id':_0x410c5a,'parent_task_id':_0x3ffd8a['parentTaskId'],'network_id':_0x3ffd8a[_0x2efff2(0x15d)],'transport':_0x3ffd8a[_0x2efff2(0x136)],'status':_0x4b4fb6,'duration_ms':_0x458927()-_0x3eea43,'lifecycle_tracking':_0x3ffd8a[_0x2efff2(0x195)],..._0x1b5f5e!==void 0x0?{'error_code':_0xd6a61c||'send_failed','error_message':N(_0x1b5f5e)}:{}})));};_0x1c59a4(_0x2e6703(0x185),null);try{let _0x21de47=await _0x343894[_0x2e6703(0x130)](),_0x150f17=j(_0x21de47);if(_0x150f17)_0x1c59a4('delivered',_0x150f17);else{if(_0x21de47?.['ok']===!0x1||_0x21de47?.[_0x2e6703(0x152)])_0x1c59a4(_0x2e6703(0x166),_0x150f17,_0x21de47?.['error']||_0x2e6703(0x19c),_0x2e6703(0x187));else _0x1c59a4(_0x2e6703(0x166),null,_0x2e6703(0x16c),'missing_task_id');}return _0x21de47;}catch(_0x40936f){throw _0x1c59a4(_0x2e6703(0x166),null,_0x40936f,'send_failed'),_0x40936f;}}function a0_0xc728(){const _0x1fde7f=['transport','application/json','duration_ms','93ixhzLr','\x20task_id=','read','lifecycle_tracking','297mnBJBJ','to_alias','text','not_tracked','565082kumgiw','message','text/event-stream','startsWith','task_id','alias','parse','toAlias','s...','sdk-','abort','SSE\x20reconnecting\x20in\x20','broadcast','toTimeString','task.send.start','token','json','error','connect','signal','call','get_inbox','task.replied','1307658wQPtde','inbox\x20error:\x20','sleep','now','sseAbort','networkId','split','result','normal','POST','processInbox','task.started','102740TddmCd','tools/call','failed','replace','task.ack','heartbeat\x20failed:\x20','\x20transport=','sdk','CommHub\x20response\x20omitted\x20task_id','<unknown>','get_all_status','error_message','server','error_code','Authorization','5yAULPJ','resumeId','connectSSE','pop','task.expired','disconnect','min','Bearer\x20','match','report_status','\x20error=','from_session','103570fIHYKN','\x20parent_task_id=','stringify','body','new_task','connected','sending','send_message','send_rejected','heartbeatTimer','application/json,\x20text/event-stream','parentTaskId','data:\x20','status','heartbeatInterval','task','ack_inbox','name','type','registered','/events/','\x20to=','lifecycleTracking','network_id','completed','task.send.failed','log','content','emit','CommHub\x20rejected\x20task','18XJPBYp','unknown\x20error','reconnectDelay','<missing>','fromAlias','url','<pending>','reply','send_task','agent','autoConnect','\x20lifecycle=','116163PljwSL','SSE\x20connected','message_id','/mcp','796544eAKWEm','idle','818iCzNYz','cwd','getReader','send','disconnected','new_message','catch','slice','running'];a0_0xc728=function(){return _0x1fde7f;};return a0_0xc728();}async function Y(_0x5823f7,_0x100e37){const _0x1bb699=a0_0x3628a8;return X({'fromAlias':_0x5823f7[_0x1bb699(0x1a1)],'toAlias':_0x5823f7[_0x1bb699(0x146)],'parentTaskId':_0x5823f7[_0x1bb699(0x18a)]||null,'networkId':_0x5823f7[_0x1bb699(0x15d)]||null,'transport':'mcp_http','lifecycleTracking':_0x1bb699(0x140)},_0x100e37);}class $ extends a0_0x150ff0{[a0_0x3628a8(0x1a2)];[a0_0x3628a8(0x146)];[a0_0x3628a8(0x150)];[a0_0x3628a8(0x1a6)];[a0_0x3628a8(0x174)];[a0_0x3628a8(0x18d)];[a0_0x3628a8(0x19f)];['heartbeatTimer'];[a0_0x3628a8(0x15c)];[a0_0x3628a8(0x135)]=!0x1;constructor(_0x2f1714){const _0x242ed2=a0_0x3628a8;super();if(this[_0x242ed2(0x1a2)]=_0x2f1714[_0x242ed2(0x1a2)][_0x242ed2(0x167)](/\/$/,''),this['alias']=_0x2f1714['alias'],this[_0x242ed2(0x150)]=_0x2f1714[_0x242ed2(0x150)],this[_0x242ed2(0x1a6)]=_0x2f1714['agent']||_0x242ed2(0x16b),this['resumeId']=_0x242ed2(0x14a)+_0x2f1714['alias']+'-'+Date[_0x242ed2(0x15b)]()['toString'](0x24),this['heartbeatInterval']=_0x2f1714['heartbeatInterval']??0x2bf20,this[_0x242ed2(0x19f)]=_0x2f1714[_0x242ed2(0x19f)]??0xbb8,_0x2f1714[_0x242ed2(0x1a7)]!==!0x1)this[_0x242ed2(0x153)]();}[a0_0x3628a8(0x199)](_0x5ccbf1){const _0x2450e6=a0_0x3628a8;console[_0x2450e6(0x199)]('['+new Date()[_0x2450e6(0x14e)]()['slice'](0x0,0x8)+']\x20[commhub:'+this[_0x2450e6(0x146)]+']\x20'+_0x5ccbf1);}async[a0_0x3628a8(0x155)](_0x55e918,_0xfedba2){const _0x30fd76=a0_0x3628a8;let _0x478e7b={'Content-Type':_0x30fd76(0x137),'Accept':_0x30fd76(0x189)};if(this[_0x30fd76(0x150)])_0x478e7b[_0x30fd76(0x172)]='Bearer\x20'+this[_0x30fd76(0x150)];let _0x29ca03=await(await fetch(this[_0x30fd76(0x1a2)]+_0x30fd76(0x12a),{'method':_0x30fd76(0x161),'headers':_0x478e7b,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date[_0x30fd76(0x15b)](),'method':_0x30fd76(0x165),'params':{'name':_0x55e918,'arguments':_0xfedba2}})}))[_0x30fd76(0x13f)](),_0x15033b=_0x29ca03[_0x30fd76(0x17b)](/data: (.+)/),_0x564cba=_0x15033b?JSON[_0x30fd76(0x147)](_0x15033b[0x1]):JSON['parse'](_0x29ca03),_0x32fd60=_0x564cba?.[_0x30fd76(0x15f)]?.[_0x30fd76(0x19a)]?.[0x0]?.[_0x30fd76(0x13f)];return _0x32fd60?JSON['parse'](_0x32fd60):_0x564cba;}async[a0_0x3628a8(0x153)](){const _0x1c22bf=a0_0x3628a8;if(this[_0x1c22bf(0x135)])return;this['running']=!0x0,await this['status'](_0x1c22bf(0x12c)),this['log'](_0x1c22bf(0x192)),this[_0x1c22bf(0x188)]=setInterval(()=>{const _0x433ac0=_0x1c22bf;this[_0x433ac0(0x18c)](_0x433ac0(0x12c))[_0x433ac0(0x133)](_0x26bbe3=>this[_0x433ac0(0x199)](_0x433ac0(0x169)+_0x26bbe3[_0x433ac0(0x142)]));},this[_0x1c22bf(0x18d)]),this[_0x1c22bf(0x175)]();}async[a0_0x3628a8(0x178)](){const _0x4059ab=a0_0x3628a8;if(this[_0x4059ab(0x135)]=!0x1,this[_0x4059ab(0x15c)]?.[_0x4059ab(0x14b)](),this[_0x4059ab(0x188)])clearInterval(this[_0x4059ab(0x188)]);await this[_0x4059ab(0x18c)]('offline')[_0x4059ab(0x133)](()=>{}),this[_0x4059ab(0x199)]('disconnected');}async[a0_0x3628a8(0x130)](_0x270c37,_0x3fd25d,_0x2eb98e=a0_0x3628a8(0x160)){const _0x54c92f=a0_0x3628a8;return Y({'alias':_0x270c37,'fromAlias':this[_0x54c92f(0x146)]},{'log':_0x41a0c2=>console['log'](_0x41a0c2),'send':()=>this[_0x54c92f(0x155)](_0x54c92f(0x1a5),{'alias':_0x270c37,'task':_0x3fd25d,'priority':_0x2eb98e,'from_session':this['alias']})});}async[a0_0x3628a8(0x142)](_0xaf02ec,_0x53bb50){const _0x5de84b=a0_0x3628a8;return this[_0x5de84b(0x155)](_0x5de84b(0x186),{'alias':_0xaf02ec,'message':_0x53bb50,'from_session':this[_0x5de84b(0x146)]});}async[a0_0x3628a8(0x1a4)](_0x208860,_0x25e517,_0x445f75=a0_0x3628a8(0x197)){const _0x1279c9=a0_0x3628a8;return this[_0x1279c9(0x155)]('send_reply',{'in_reply_to':_0x208860,'text':_0x25e517,'status':_0x445f75});}async['status'](_0x37e6e5,_0x337ad4){const _0x1569e0=a0_0x3628a8;return this[_0x1569e0(0x155)](_0x1569e0(0x17c),{'resume_id':this['resumeId'],'alias':this[_0x1569e0(0x146)],'status':_0x37e6e5,'server':a0_0x4846f8(),'hostname':a0_0x4846f8(),'agent':this[_0x1569e0(0x1a6)],'project_dir':process[_0x1569e0(0x12e)](),..._0x337ad4});}async['getAllStatus'](){const _0x323f3c=a0_0x3628a8;return this[_0x323f3c(0x155)](_0x323f3c(0x16e),{});}async[a0_0x3628a8(0x14d)](_0x54796f,_0x19d543){const _0x470134=a0_0x3628a8;return this[_0x470134(0x155)]('broadcast',{'message':_0x54796f,'filter_server':_0x19d543?.[_0x470134(0x170)],'filter_status':_0x19d543?.[_0x470134(0x18c)]});}async[a0_0x3628a8(0x175)](){const _0xdf9357=a0_0x3628a8;let _0x1da926=encodeURIComponent(this[_0xdf9357(0x146)]),_0x51570d=this[_0xdf9357(0x1a2)]+_0xdf9357(0x193)+_0x1da926,_0x18e7fc=this[_0xdf9357(0x19f)];while(this[_0xdf9357(0x135)]){try{this['sseAbort']=new AbortController();let _0x352002={'Accept':_0xdf9357(0x143)};if(this[_0xdf9357(0x150)])_0x352002['Authorization']=_0xdf9357(0x17a)+this[_0xdf9357(0x150)];let _0xa91b49=await fetch(_0x51570d,{'headers':_0x352002,'signal':this[_0xdf9357(0x15c)][_0xdf9357(0x154)]});if(!_0xa91b49['ok']||!_0xa91b49[_0xdf9357(0x182)]){this[_0xdf9357(0x199)]('SSE\x20failed:\x20'+_0xa91b49[_0xdf9357(0x18c)]),await this[_0xdf9357(0x15a)](_0x18e7fc),_0x18e7fc=Math[_0xdf9357(0x179)](_0x18e7fc*1.5,0xea60);continue;}_0x18e7fc=this[_0xdf9357(0x19f)];let _0x5501bd=_0xa91b49['body'][_0xdf9357(0x12f)](),_0xcbdb56=new TextDecoder(),_0x2f9882='';while(this[_0xdf9357(0x135)]){let {done:_0x22f34a,value:_0x307b31}=await _0x5501bd[_0xdf9357(0x13b)]();if(_0x22f34a)break;_0x2f9882+=_0xcbdb56['decode'](_0x307b31,{'stream':!0x0});let _0x57628c=_0x2f9882[_0xdf9357(0x15e)]('\x0a');_0x2f9882=_0x57628c[_0xdf9357(0x176)]()||'';for(let _0x27d0d6 of _0x57628c){if(!_0x27d0d6[_0xdf9357(0x144)](_0xdf9357(0x18b)))continue;try{let _0x1572df=JSON['parse'](_0x27d0d6[_0xdf9357(0x134)](0x6));if(_0x1572df['type']===_0xdf9357(0x184)){this[_0xdf9357(0x199)](_0xdf9357(0x128)),this[_0xdf9357(0x19b)](_0xdf9357(0x184));continue;}if(_0x1572df[_0xdf9357(0x191)]===_0xdf9357(0x183)||_0x1572df['type']===_0xdf9357(0x132)||_0x1572df[_0xdf9357(0x191)]===_0xdf9357(0x14d))await this['processInbox']();}catch{}}}}catch(_0x1c09ff){if(_0x1c09ff[_0xdf9357(0x190)]==='AbortError')break;this[_0xdf9357(0x19b)](_0xdf9357(0x152),_0x1c09ff),this[_0xdf9357(0x199)]('SSE\x20error:\x20'+_0x1c09ff[_0xdf9357(0x142)]);}if(this['running'])this[_0xdf9357(0x19b)](_0xdf9357(0x131)),this[_0xdf9357(0x199)](_0xdf9357(0x14c)+_0x18e7fc/0x3e8+_0xdf9357(0x149)),await this['sleep'](_0x18e7fc),_0x18e7fc=Math[_0xdf9357(0x179)](_0x18e7fc*1.5,0xea60);}}async[a0_0x3628a8(0x162)](){const _0x3d7691=a0_0x3628a8;try{let _0x323eed=(await this['call'](_0x3d7691(0x156),{'alias':this[_0x3d7691(0x146)],'limit':0xa}))?.['messages']||[];for(let _0x4f66f9 of _0x323eed)await this[_0x3d7691(0x155)](_0x3d7691(0x18f),{'alias':this['alias'],'message_id':_0x4f66f9['id']}),this['log']('←\x20'+_0x4f66f9[_0x3d7691(0x17e)]+':\x20'+_0x4f66f9[_0x3d7691(0x19a)][_0x3d7691(0x134)](0x0,0x3c)),this[_0x3d7691(0x19b)](_0x3d7691(0x18e),_0x4f66f9),this[_0x3d7691(0x19b)](_0x3d7691(0x142),_0x4f66f9);}catch(_0xbc58fe){this[_0x3d7691(0x199)](_0x3d7691(0x159)+_0xbc58fe[_0x3d7691(0x142)]);}}[a0_0x3628a8(0x15a)](_0x152e0c){return new Promise(_0x103ae6=>setTimeout(_0x103ae6,_0x152e0c));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x4b625b=a0_0x2801;(function(_0x51577b,_0x2144d1){const _0x53a1d6=a0_0x2801,_0x577539=_0x51577b();while(!![]){try{const _0x335187=parseInt(_0x53a1d6(0x1e5))/0x1+-parseInt(_0x53a1d6(0x1fa))/0x2+parseInt(_0x53a1d6(0x1f4))/0x3*(-parseInt(_0x53a1d6(0x1c4))/0x4)+parseInt(_0x53a1d6(0x1b4))/0x5*(-parseInt(_0x53a1d6(0x1d6))/0x6)+-parseInt(_0x53a1d6(0x1f6))/0x7*(parseInt(_0x53a1d6(0x1d8))/0x8)+parseInt(_0x53a1d6(0x204))/0x9+parseInt(_0x53a1d6(0x197))/0xa*(parseInt(_0x53a1d6(0x20c))/0xb);if(_0x335187===_0x2144d1)break;else _0x577539['push'](_0x577539['shift']());}catch(_0x5c179c){_0x577539['push'](_0x577539['shift']());}}}(a0_0x2684,0xb0b0c));function a0_0x2801(_0x128780,_0x9367ff){_0x128780=_0x128780-0x18c;const _0x2684b0=a0_0x2684();let _0x2801d4=_0x2684b0[_0x128780];return _0x2801d4;}import{EventEmitter as a0_0x5b4f37}from'events';import{hostname as a0_0x43d8d9}from'os';function a0_0x2684(){const _0xa33799=['get_inbox','now','normal','network_id','send_failed','idle','url','stringify','call','parentTaskId','<unknown>','3284qsUGwC','token','heartbeatInterval','unknown\x20error','SSE\x20failed:\x20','status','not_tracked','registered','SSE\x20connected','send_message','/mcp','toTimeString','reconnectDelay','send_reply','\x20to=','offline','sleep','CommHub\x20response\x20omitted\x20task_id','6940806vmEETm','send_task','3857512YltwLq','mcp_http','pop','from_alias','\x20from=','content','[commhub:task]\x20','completed','networkId','alias','read','task.expired','send','876608dxcbmd','\x20duration_ms=','[REDACTED]','parse','getAllStatus','text','type','sdk','Bearer\x20','slice','<missing>','cwd','\x20parent_task_id=','disconnect','error_code','4038rvBlvR','min','21AzELEv','SSE\x20reconnecting\x20in\x20','agent','running','2681656mSzYHg','2.0','getReader','log','lifecycle_tracking','AbortError','task.send.failed','signal','from_session','messages','362322wfLMQY','broadcast','SSE\x20error:\x20','send_rejected','resumeId','heartbeatTimer','split','get_all_status','6677165oqnQVd','text/event-stream','task','error','CommHub\x20rejected\x20task','ack_inbox','connected','name','Authorization','\x20lifecycle=','emit','task.started','\x20error=','new_task','80LFUIwH','\x20network_id=','transport','to_alias','autoConnect','tools/call','task.replied','failed','reply','processInbox','catch','connect','\x20transport=','s...','sseAbort','task.send.start','delivered','missing_task_id','replace','heartbeat\x20failed:\x20','disconnected','data:\x20','duration_ms','task_id','match','fromAlias','task.ack','parent_task_id','body','5QQWQxI','message','abort','message_id','connectSSE'];a0_0x2684=function(){return _0xa33799;};return a0_0x2684();}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2a1344,_0x47de0b)=>(_0x2a1344??_0x47de0b)[a0_0x4b625b(0x1a9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x4b625b(0x1ee)](0x0,0xf0);function N(_0x3b6f43){const _0x3421e4=a0_0x4b625b;return(_0x3b6f43 instanceof Error?_0x3b6f43[_0x3421e4(0x1b5)]:String(_0x3b6f43??_0x3421e4(0x1c7)))['replace'](K,_0x3421e4(0x1e7))[_0x3421e4(0x1a9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x30d117,_0x97fc4d=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x2b26bb=a0_0x4b625b;if(_0x97fc4d)return JSON[_0x2b26bb(0x1c0)](_0x30d117);let _0x305eac=L(_0x30d117[_0x2b26bb(0x1b2)],_0x2b26bb(0x1ef)),_0x9d516a=L(_0x30d117[_0x2b26bb(0x1ae)],'<pending>'),_0x5029b6=_0x30d117[_0x2b26bb(0x1f3)]?_0x2b26bb(0x195)+_0x30d117[_0x2b26bb(0x1f3)]+':'+(_0x30d117['error_message']??''):'';return _0x2b26bb(0x1de)+_0x30d117[_0x2b26bb(0x1c9)]+_0x2b26bb(0x1dc)+L(_0x30d117[_0x2b26bb(0x1db)],'<unknown>')+_0x2b26bb(0x1d2)+L(_0x30d117[_0x2b26bb(0x19a)],_0x2b26bb(0x1c3))+'\x20task_id='+_0x9d516a+_0x2b26bb(0x1f1)+_0x305eac+_0x2b26bb(0x198)+L(_0x30d117[_0x2b26bb(0x1bc)],_0x2b26bb(0x1c3))+_0x2b26bb(0x1a3)+_0x30d117[_0x2b26bb(0x199)]+_0x2b26bb(0x1e6)+_0x30d117[_0x2b26bb(0x1ad)]+_0x2b26bb(0x192)+_0x30d117[_0x2b26bb(0x1fe)]+_0x5029b6;}function U(_0x548422){const _0x14d7b6=a0_0x4b625b;return{'event':{'sending':_0x14d7b6(0x1a6),'delivered':'task.send.delivered','failed':_0x14d7b6(0x200),'acked':_0x14d7b6(0x1b1),'started':_0x14d7b6(0x194),'replied':_0x14d7b6(0x19d),'expired':_0x14d7b6(0x1e3)}[_0x548422[_0x14d7b6(0x1c9)]],..._0x548422};}function j(_0x47f2ee){const _0x492350=a0_0x4b625b;let _0x6df4b1=_0x47f2ee?.[_0x492350(0x1ae)]||_0x47f2ee?.[_0x492350(0x1b7)]||_0x47f2ee?.['id'];if(_0x6df4b1)return String(_0x6df4b1);let _0xf06f=_0x47f2ee?.[_0x492350(0x1dd)]?.[0x0]?.[_0x492350(0x1ea)];if(typeof _0xf06f!=='string')return null;try{let _0x44817e=JSON[_0x492350(0x1e8)](_0xf06f);return _0x44817e?.['task_id']||_0x44817e?.['message_id']||_0x44817e?.['id']||null;}catch{return null;}}async function X(_0x3c38fc,_0x4021f9){const _0x11020d=a0_0x4b625b;let _0x131bb5=_0x4021f9[_0x11020d(0x1ba)]??Date[_0x11020d(0x1ba)],_0x196498=_0x131bb5(),_0x434fd5=(_0x3e2cf6,_0x1c32ea,_0x375d38,_0x446e47)=>{const _0x2895a1=_0x11020d;_0x4021f9[_0x2895a1(0x1fd)](O(U({'from_alias':_0x3c38fc[_0x2895a1(0x1b0)],'to_alias':_0x3c38fc['toAlias'],'task_id':_0x1c32ea,'parent_task_id':_0x3c38fc['parentTaskId'],'network_id':_0x3c38fc[_0x2895a1(0x1e0)],'transport':_0x3c38fc[_0x2895a1(0x199)],'status':_0x3e2cf6,'duration_ms':_0x131bb5()-_0x196498,'lifecycle_tracking':_0x3c38fc['lifecycleTracking'],..._0x375d38!==void 0x0?{'error_code':_0x446e47||_0x2895a1(0x1bd),'error_message':N(_0x375d38)}:{}})));};_0x434fd5('sending',null);try{let _0x11aba1=await _0x4021f9[_0x11020d(0x1e4)](),_0x58f78c=j(_0x11aba1);if(_0x58f78c)_0x434fd5(_0x11020d(0x1a7),_0x58f78c);else{if(_0x11aba1?.['ok']===!0x1||_0x11aba1?.[_0x11020d(0x18c)])_0x434fd5(_0x11020d(0x19e),_0x58f78c,_0x11aba1?.[_0x11020d(0x18c)]||_0x11020d(0x18d),_0x11020d(0x207));else _0x434fd5(_0x11020d(0x19e),null,_0x11020d(0x1d5),_0x11020d(0x1a8));}return _0x11aba1;}catch(_0x5271f0){throw _0x434fd5(_0x11020d(0x19e),null,_0x5271f0,'send_failed'),_0x5271f0;}}async function Y(_0x314407,_0x5ef011){const _0x5a8537=a0_0x4b625b;return X({'fromAlias':_0x314407[_0x5a8537(0x1b0)],'toAlias':_0x314407[_0x5a8537(0x1e1)],'parentTaskId':_0x314407[_0x5a8537(0x1c2)]||null,'networkId':_0x314407[_0x5a8537(0x1e0)]||null,'transport':_0x5a8537(0x1d9),'lifecycleTracking':_0x5a8537(0x1ca)},_0x5ef011);}class $ extends a0_0x5b4f37{[a0_0x4b625b(0x1bf)];['alias'];['token'];[a0_0x4b625b(0x1f8)];[a0_0x4b625b(0x208)];[a0_0x4b625b(0x1c6)];[a0_0x4b625b(0x1d0)];[a0_0x4b625b(0x209)];['sseAbort'];[a0_0x4b625b(0x1f9)]=!0x1;constructor(_0x18990b){const _0x22dff5=a0_0x4b625b;super();if(this[_0x22dff5(0x1bf)]=_0x18990b['url'][_0x22dff5(0x1a9)](/\/$/,''),this[_0x22dff5(0x1e1)]=_0x18990b[_0x22dff5(0x1e1)],this['token']=_0x18990b[_0x22dff5(0x1c5)],this[_0x22dff5(0x1f8)]=_0x18990b[_0x22dff5(0x1f8)]||_0x22dff5(0x1ec),this[_0x22dff5(0x208)]='sdk-'+_0x18990b[_0x22dff5(0x1e1)]+'-'+Date[_0x22dff5(0x1ba)]()['toString'](0x24),this[_0x22dff5(0x1c6)]=_0x18990b[_0x22dff5(0x1c6)]??0x2bf20,this[_0x22dff5(0x1d0)]=_0x18990b[_0x22dff5(0x1d0)]??0xbb8,_0x18990b[_0x22dff5(0x19b)]!==!0x1)this[_0x22dff5(0x1a2)]();}[a0_0x4b625b(0x1fd)](_0x172949){const _0x143b04=a0_0x4b625b;console[_0x143b04(0x1fd)]('['+new Date()[_0x143b04(0x1cf)]()['slice'](0x0,0x8)+']\x20[commhub:'+this[_0x143b04(0x1e1)]+']\x20'+_0x172949);}async[a0_0x4b625b(0x1c1)](_0x380fc9,_0x173a01){const _0x42326b=a0_0x4b625b;let _0x573087={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this[_0x42326b(0x1c5)])_0x573087['Authorization']=_0x42326b(0x1ed)+this[_0x42326b(0x1c5)];let _0x944ce6=await(await fetch(this['url']+_0x42326b(0x1ce),{'method':'POST','headers':_0x573087,'body':JSON[_0x42326b(0x1c0)]({'jsonrpc':_0x42326b(0x1fb),'id':Date[_0x42326b(0x1ba)](),'method':_0x42326b(0x19c),'params':{'name':_0x380fc9,'arguments':_0x173a01}})}))[_0x42326b(0x1ea)](),_0x39059d=_0x944ce6[_0x42326b(0x1af)](/data: (.+)/),_0x3bdb77=_0x39059d?JSON[_0x42326b(0x1e8)](_0x39059d[0x1]):JSON[_0x42326b(0x1e8)](_0x944ce6),_0x154353=_0x3bdb77?.['result']?.['content']?.[0x0]?.[_0x42326b(0x1ea)];return _0x154353?JSON[_0x42326b(0x1e8)](_0x154353):_0x3bdb77;}async[a0_0x4b625b(0x1a2)](){const _0x2b32b4=a0_0x4b625b;if(this[_0x2b32b4(0x1f9)])return;this['running']=!0x0,await this[_0x2b32b4(0x1c9)](_0x2b32b4(0x1be)),this[_0x2b32b4(0x1fd)](_0x2b32b4(0x1cb)),this[_0x2b32b4(0x209)]=setInterval(()=>{const _0x201bca=_0x2b32b4;this[_0x201bca(0x1c9)](_0x201bca(0x1be))[_0x201bca(0x1a1)](_0x33612d=>this[_0x201bca(0x1fd)](_0x201bca(0x1aa)+_0x33612d[_0x201bca(0x1b5)]));},this[_0x2b32b4(0x1c6)]),this[_0x2b32b4(0x1b8)]();}async[a0_0x4b625b(0x1f2)](){const _0xd51ac7=a0_0x4b625b;if(this[_0xd51ac7(0x1f9)]=!0x1,this[_0xd51ac7(0x1a5)]?.[_0xd51ac7(0x1b6)](),this['heartbeatTimer'])clearInterval(this[_0xd51ac7(0x209)]);await this['status'](_0xd51ac7(0x1d3))['catch'](()=>{}),this[_0xd51ac7(0x1fd)](_0xd51ac7(0x1ab));}async[a0_0x4b625b(0x1e4)](_0x34ba56,_0x53a2e1,_0x2aafac=a0_0x4b625b(0x1bb)){const _0x440e2d=a0_0x4b625b;return Y({'alias':_0x34ba56,'fromAlias':this['alias']},{'log':_0x2bbf37=>console[_0x440e2d(0x1fd)](_0x2bbf37),'send':()=>this[_0x440e2d(0x1c1)](_0x440e2d(0x1d7),{'alias':_0x34ba56,'task':_0x53a2e1,'priority':_0x2aafac,'from_session':this[_0x440e2d(0x1e1)]})});}async[a0_0x4b625b(0x1b5)](_0x5d216c,_0x587c48){const _0xf20267=a0_0x4b625b;return this[_0xf20267(0x1c1)](_0xf20267(0x1cd),{'alias':_0x5d216c,'message':_0x587c48,'from_session':this[_0xf20267(0x1e1)]});}async[a0_0x4b625b(0x19f)](_0x491865,_0x5dca45,_0x38f3ac=a0_0x4b625b(0x1df)){const _0x1bdeef=a0_0x4b625b;return this[_0x1bdeef(0x1c1)](_0x1bdeef(0x1d1),{'in_reply_to':_0x491865,'text':_0x5dca45,'status':_0x38f3ac});}async['status'](_0xe027f4,_0x2db43b){const _0x37ce8b=a0_0x4b625b;return this[_0x37ce8b(0x1c1)]('report_status',{'resume_id':this[_0x37ce8b(0x208)],'alias':this[_0x37ce8b(0x1e1)],'status':_0xe027f4,'server':a0_0x43d8d9(),'hostname':a0_0x43d8d9(),'agent':this['agent'],'project_dir':process[_0x37ce8b(0x1f0)](),..._0x2db43b});}async[a0_0x4b625b(0x1e9)](){const _0x46ab1c=a0_0x4b625b;return this[_0x46ab1c(0x1c1)](_0x46ab1c(0x20b),{});}async['broadcast'](_0x49c4d5,_0x2064ed){const _0x5db4a6=a0_0x4b625b;return this[_0x5db4a6(0x1c1)](_0x5db4a6(0x205),{'message':_0x49c4d5,'filter_server':_0x2064ed?.['server'],'filter_status':_0x2064ed?.['status']});}async[a0_0x4b625b(0x1b8)](){const _0x54545b=a0_0x4b625b;let _0x5d1e35=encodeURIComponent(this[_0x54545b(0x1e1)]),_0x37aff0=this[_0x54545b(0x1bf)]+'/events/'+_0x5d1e35,_0x3361d1=this[_0x54545b(0x1d0)];while(this[_0x54545b(0x1f9)]){try{this[_0x54545b(0x1a5)]=new AbortController();let _0x3307be={'Accept':_0x54545b(0x20d)};if(this['token'])_0x3307be[_0x54545b(0x191)]=_0x54545b(0x1ed)+this[_0x54545b(0x1c5)];let _0x1c4d1f=await fetch(_0x37aff0,{'headers':_0x3307be,'signal':this['sseAbort'][_0x54545b(0x201)]});if(!_0x1c4d1f['ok']||!_0x1c4d1f[_0x54545b(0x1b3)]){this[_0x54545b(0x1fd)](_0x54545b(0x1c8)+_0x1c4d1f[_0x54545b(0x1c9)]),await this[_0x54545b(0x1d4)](_0x3361d1),_0x3361d1=Math[_0x54545b(0x1f5)](_0x3361d1*1.5,0xea60);continue;}_0x3361d1=this['reconnectDelay'];let _0x11c904=_0x1c4d1f[_0x54545b(0x1b3)][_0x54545b(0x1fc)](),_0x1e5db9=new TextDecoder(),_0x48028d='';while(this[_0x54545b(0x1f9)]){let {done:_0x199f59,value:_0x467f92}=await _0x11c904[_0x54545b(0x1e2)]();if(_0x199f59)break;_0x48028d+=_0x1e5db9['decode'](_0x467f92,{'stream':!0x0});let _0x5ee8d6=_0x48028d[_0x54545b(0x20a)]('\x0a');_0x48028d=_0x5ee8d6[_0x54545b(0x1da)]()||'';for(let _0x89a825 of _0x5ee8d6){if(!_0x89a825['startsWith'](_0x54545b(0x1ac)))continue;try{let _0x5300eb=JSON[_0x54545b(0x1e8)](_0x89a825[_0x54545b(0x1ee)](0x6));if(_0x5300eb[_0x54545b(0x1eb)]===_0x54545b(0x18f)){this[_0x54545b(0x1fd)](_0x54545b(0x1cc)),this[_0x54545b(0x193)]('connected');continue;}if(_0x5300eb[_0x54545b(0x1eb)]===_0x54545b(0x196)||_0x5300eb[_0x54545b(0x1eb)]==='new_message'||_0x5300eb[_0x54545b(0x1eb)]===_0x54545b(0x205))await this[_0x54545b(0x1a0)]();}catch{}}}}catch(_0xb13b1b){if(_0xb13b1b[_0x54545b(0x190)]===_0x54545b(0x1ff))break;this[_0x54545b(0x193)](_0x54545b(0x18c),_0xb13b1b),this[_0x54545b(0x1fd)](_0x54545b(0x206)+_0xb13b1b[_0x54545b(0x1b5)]);}if(this[_0x54545b(0x1f9)])this[_0x54545b(0x193)](_0x54545b(0x1ab)),this[_0x54545b(0x1fd)](_0x54545b(0x1f7)+_0x3361d1/0x3e8+_0x54545b(0x1a4)),await this[_0x54545b(0x1d4)](_0x3361d1),_0x3361d1=Math[_0x54545b(0x1f5)](_0x3361d1*1.5,0xea60);}}async[a0_0x4b625b(0x1a0)](){const _0x55bfc1=a0_0x4b625b;try{let _0x354fb7=(await this['call'](_0x55bfc1(0x1b9),{'alias':this[_0x55bfc1(0x1e1)],'limit':0xa}))?.[_0x55bfc1(0x203)]||[];for(let _0x47209e of _0x354fb7)await this['call'](_0x55bfc1(0x18e),{'alias':this[_0x55bfc1(0x1e1)],'message_id':_0x47209e['id']}),this['log']('←\x20'+_0x47209e[_0x55bfc1(0x202)]+':\x20'+_0x47209e[_0x55bfc1(0x1dd)][_0x55bfc1(0x1ee)](0x0,0x3c)),this[_0x55bfc1(0x193)](_0x55bfc1(0x20e),_0x47209e),this['emit'](_0x55bfc1(0x1b5),_0x47209e);}catch(_0x3a7b1d){this[_0x55bfc1(0x1fd)]('inbox\x20error:\x20'+_0x3a7b1d[_0x55bfc1(0x1b5)]);}}[a0_0x4b625b(0x1d4)](_0x9ecda9){return new Promise(_0x5c0542=>setTimeout(_0x5c0542,_0x9ecda9));}}var F=$;export{F as default,$ as CommHub};
|