@sleep2agi/agent-network 2.3.0-preview.93 → 2.3.0-preview.96

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_0x348570=a0_0x5ee7;(function(_0x2eaf66,_0x3a7f85){const _0x4f6759=a0_0x5ee7,_0x5ee022=_0x2eaf66();while(!![]){try{const _0x520cc3=parseInt(_0x4f6759(0x152))/0x1+-parseInt(_0x4f6759(0x145))/0x2*(parseInt(_0x4f6759(0x17d))/0x3)+-parseInt(_0x4f6759(0x10b))/0x4*(-parseInt(_0x4f6759(0x134))/0x5)+-parseInt(_0x4f6759(0x171))/0x6*(parseInt(_0x4f6759(0x16d))/0x7)+parseInt(_0x4f6759(0x138))/0x8+-parseInt(_0x4f6759(0x110))/0x9*(-parseInt(_0x4f6759(0x17f))/0xa)+-parseInt(_0x4f6759(0x164))/0xb*(-parseInt(_0x4f6759(0x127))/0xc);if(_0x520cc3===_0x3a7f85)break;else _0x5ee022['push'](_0x5ee022['shift']());}catch(_0x52ec9d){_0x5ee022['push'](_0x5ee022['shift']());}}}(a0_0x5d04,0xcf66d));import{EventEmitter as a0_0x40df23}from'events';import{hostname as a0_0x51a0b6}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x353acb,_0x5c52a6)=>(_0x353acb??_0x5c52a6)[a0_0x348570(0x172)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function a0_0x5ee7(_0x56622d,_0x4fdd94){_0x56622d=_0x56622d-0x108;const _0x5d04b9=a0_0x5d04();let _0x5ee75b=_0x5d04b9[_0x56622d];return _0x5ee75b;}function N(_0x5265d1){const _0x2c283b=a0_0x348570;return(_0x5265d1 instanceof Error?_0x5265d1['message']:String(_0x5265d1??_0x2c283b(0x126)))[_0x2c283b(0x172)](K,'[REDACTED]')[_0x2c283b(0x172)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x3d1898,_0x4308fe=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x47bda5=a0_0x348570;if(_0x4308fe)return JSON[_0x47bda5(0x116)](_0x3d1898);let _0x385d2c=L(_0x3d1898[_0x47bda5(0x17c)],'<missing>'),_0x1083c0=L(_0x3d1898['task_id'],_0x47bda5(0x173)),_0x2bb308=_0x3d1898['error_code']?'\x20error='+_0x3d1898['error_code']+':'+(_0x3d1898[_0x47bda5(0x12f)]??''):'';return _0x47bda5(0x11b)+_0x3d1898[_0x47bda5(0x16e)]+_0x47bda5(0x14a)+L(_0x3d1898[_0x47bda5(0x12b)],'<unknown>')+_0x47bda5(0x16f)+L(_0x3d1898['to_alias'],_0x47bda5(0x140))+'\x20task_id='+_0x1083c0+'\x20parent_task_id='+_0x385d2c+_0x47bda5(0x12a)+L(_0x3d1898['network_id'],_0x47bda5(0x140))+_0x47bda5(0x175)+_0x3d1898[_0x47bda5(0x108)]+'\x20duration_ms='+_0x3d1898[_0x47bda5(0x146)]+'\x20lifecycle='+_0x3d1898[_0x47bda5(0x155)]+_0x2bb308;}function U(_0x2645ef){const _0x4d5ed5=a0_0x348570;return{'event':{'sending':_0x4d5ed5(0x13e),'delivered':'task.send.delivered','failed':_0x4d5ed5(0x177),'acked':_0x4d5ed5(0x10c),'started':_0x4d5ed5(0x14f),'replied':'task.replied','expired':_0x4d5ed5(0x128)}[_0x2645ef['status']],..._0x2645ef};}function j(_0x2cf7f4){const _0x5dfd50=a0_0x348570;let _0x385cab=_0x2cf7f4?.[_0x5dfd50(0x11f)]||_0x2cf7f4?.[_0x5dfd50(0x17a)]||_0x2cf7f4?.['id'];if(_0x385cab)return String(_0x385cab);let _0x2f191a=_0x2cf7f4?.[_0x5dfd50(0x161)]?.[0x0]?.[_0x5dfd50(0x17b)];if(typeof _0x2f191a!==_0x5dfd50(0x12d))return null;try{let _0x1bc8bb=JSON[_0x5dfd50(0x158)](_0x2f191a);return _0x1bc8bb?.[_0x5dfd50(0x11f)]||_0x1bc8bb?.[_0x5dfd50(0x17a)]||_0x1bc8bb?.['id']||null;}catch{return null;}}async function X(_0x48dfe4,_0x4c0d82){const _0x152546=a0_0x348570;let _0x35784a=_0x4c0d82[_0x152546(0x11c)]??Date[_0x152546(0x11c)],_0x5f1ce4=_0x35784a(),_0x2c2306=(_0x39e1d4,_0xe4755e,_0x341af7,_0x440cb8)=>{const _0x187009=_0x152546;_0x4c0d82[_0x187009(0x135)](O(U({'from_alias':_0x48dfe4['fromAlias'],'to_alias':_0x48dfe4['toAlias'],'task_id':_0xe4755e,'parent_task_id':_0x48dfe4[_0x187009(0x131)],'network_id':_0x48dfe4['networkId'],'transport':_0x48dfe4['transport'],'status':_0x39e1d4,'duration_ms':_0x35784a()-_0x5f1ce4,'lifecycle_tracking':_0x48dfe4['lifecycleTracking'],..._0x341af7!==void 0x0?{'error_code':_0x440cb8||_0x187009(0x130),'error_message':N(_0x341af7)}:{}})));};_0x2c2306('sending',null);try{let _0x4e02d6=await _0x4c0d82['send'](),_0x10b2ce=j(_0x4e02d6);if(_0x10b2ce)_0x2c2306(_0x152546(0x142),_0x10b2ce);else{if(_0x4e02d6?.['ok']===!0x1||_0x4e02d6?.['error'])_0x2c2306(_0x152546(0x151),_0x10b2ce,_0x4e02d6?.[_0x152546(0x11a)]||_0x152546(0x132),_0x152546(0x144));else _0x2c2306(_0x152546(0x151),null,_0x152546(0x167),_0x152546(0x10e));}return _0x4e02d6;}catch(_0x375000){throw _0x2c2306('failed',null,_0x375000,_0x152546(0x130)),_0x375000;}}async function Y(_0x295cc6,_0x446231){const _0x13c34d=a0_0x348570;return X({'fromAlias':_0x295cc6['fromAlias'],'toAlias':_0x295cc6[_0x13c34d(0x168)],'parentTaskId':_0x295cc6[_0x13c34d(0x131)]||null,'networkId':_0x295cc6['networkId']||null,'transport':_0x13c34d(0x159),'lifecycleTracking':_0x13c34d(0x16b)},_0x446231);}class $ extends a0_0x40df23{['url'];[a0_0x348570(0x168)];['token'];[a0_0x348570(0x13a)];['resumeId'];[a0_0x348570(0x139)];[a0_0x348570(0x13c)];[a0_0x348570(0x178)];[a0_0x348570(0x150)];['running']=!0x1;constructor(_0x3d5505){const _0x5d32f4=a0_0x348570;super();if(this[_0x5d32f4(0x154)]=_0x3d5505[_0x5d32f4(0x154)][_0x5d32f4(0x172)](/\/$/,''),this['alias']=_0x3d5505[_0x5d32f4(0x168)],this[_0x5d32f4(0x137)]=_0x3d5505[_0x5d32f4(0x137)],this[_0x5d32f4(0x13a)]=_0x3d5505[_0x5d32f4(0x13a)]||_0x5d32f4(0x169),this[_0x5d32f4(0x149)]=_0x5d32f4(0x15f)+_0x3d5505[_0x5d32f4(0x168)]+'-'+Date[_0x5d32f4(0x11c)]()[_0x5d32f4(0x12e)](0x24),this[_0x5d32f4(0x139)]=_0x3d5505[_0x5d32f4(0x139)]??0x2bf20,this[_0x5d32f4(0x13c)]=_0x3d5505[_0x5d32f4(0x13c)]??0xbb8,_0x3d5505['autoConnect']!==!0x1)this[_0x5d32f4(0x133)]();}['log'](_0x4fea59){const _0x541127=a0_0x348570;console[_0x541127(0x135)]('['+new Date()[_0x541127(0x121)]()['slice'](0x0,0x8)+_0x541127(0x14e)+this[_0x541127(0x168)]+']\x20'+_0x4fea59);}async[a0_0x348570(0x13f)](_0x1d165b,_0x2ac8f5){const _0x5b986e=a0_0x348570;let _0x7b5d50={'Content-Type':_0x5b986e(0x141),'Accept':_0x5b986e(0x166)};if(this[_0x5b986e(0x137)])_0x7b5d50[_0x5b986e(0x14c)]=_0x5b986e(0x176)+this[_0x5b986e(0x137)];let _0x27724b=await(await fetch(this[_0x5b986e(0x154)]+'/mcp',{'method':_0x5b986e(0x11e),'headers':_0x7b5d50,'body':JSON[_0x5b986e(0x116)]({'jsonrpc':_0x5b986e(0x119),'id':Date[_0x5b986e(0x11c)](),'method':_0x5b986e(0x14d),'params':{'name':_0x1d165b,'arguments':_0x2ac8f5}})}))['text'](),_0x317428=_0x27724b['match'](/data: (.+)/),_0x28567c=_0x317428?JSON[_0x5b986e(0x158)](_0x317428[0x1]):JSON[_0x5b986e(0x158)](_0x27724b),_0x31b5e3=_0x28567c?.['result']?.[_0x5b986e(0x161)]?.[0x0]?.[_0x5b986e(0x17b)];return _0x31b5e3?JSON['parse'](_0x31b5e3):_0x28567c;}async[a0_0x348570(0x133)](){const _0x2b42cb=a0_0x348570;if(this[_0x2b42cb(0x16c)])return;this[_0x2b42cb(0x16c)]=!0x0,await this['status']('idle'),this[_0x2b42cb(0x135)](_0x2b42cb(0x12c)),this[_0x2b42cb(0x178)]=setInterval(()=>{const _0x26387a=_0x2b42cb;this[_0x26387a(0x16e)](_0x26387a(0x15a))[_0x26387a(0x117)](_0x374edc=>this[_0x26387a(0x135)](_0x26387a(0x124)+_0x374edc[_0x26387a(0x15d)]));},this['heartbeatInterval']),this[_0x2b42cb(0x129)]();}async[a0_0x348570(0x143)](){const _0x5c7c11=a0_0x348570;if(this['running']=!0x1,this['sseAbort']?.[_0x5c7c11(0x147)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0x5c7c11(0x16e)]('offline')[_0x5c7c11(0x117)](()=>{}),this[_0x5c7c11(0x135)]('disconnected');}async[a0_0x348570(0x157)](_0x49bfa0,_0x316f37,_0x37cdfb=a0_0x348570(0x10d)){const _0x1ef120=a0_0x348570;return Y({'alias':_0x49bfa0,'fromAlias':this[_0x1ef120(0x168)]},{'log':_0x1c0352=>console[_0x1ef120(0x135)](_0x1c0352),'send':()=>this[_0x1ef120(0x13f)]('send_task',{'alias':_0x49bfa0,'task':_0x316f37,'priority':_0x37cdfb,'from_session':this[_0x1ef120(0x168)]})});}async[a0_0x348570(0x15d)](_0x50f2d2,_0x2c03d1){const _0x42644d=a0_0x348570;return this[_0x42644d(0x13f)](_0x42644d(0x163),{'alias':_0x50f2d2,'message':_0x2c03d1,'from_session':this[_0x42644d(0x168)]});}async[a0_0x348570(0x180)](_0x62faed,_0x50aedb,_0x30e958=a0_0x348570(0x156)){const _0x5c96fa=a0_0x348570;return this['call'](_0x5c96fa(0x111),{'in_reply_to':_0x62faed,'text':_0x50aedb,'status':_0x30e958});}async[a0_0x348570(0x16e)](_0x4f080c,_0x1d70ed){const _0x5ca3de=a0_0x348570;return this[_0x5ca3de(0x13f)](_0x5ca3de(0x122),{'resume_id':this['resumeId'],'alias':this[_0x5ca3de(0x168)],'status':_0x4f080c,'server':a0_0x51a0b6(),'hostname':a0_0x51a0b6(),'agent':this[_0x5ca3de(0x13a)],'project_dir':process[_0x5ca3de(0x10a)](),..._0x1d70ed});}async[a0_0x348570(0x113)](){const _0x551191=a0_0x348570;return this[_0x551191(0x13f)](_0x551191(0x120),{});}async[a0_0x348570(0x15c)](_0x1af99f,_0x2cf5a5){const _0x13ee2a=a0_0x348570;return this[_0x13ee2a(0x13f)]('broadcast',{'message':_0x1af99f,'filter_server':_0x2cf5a5?.['server'],'filter_status':_0x2cf5a5?.[_0x13ee2a(0x16e)]});}async[a0_0x348570(0x129)](){const _0x325ff1=a0_0x348570;let _0x240a44=encodeURIComponent(this[_0x325ff1(0x168)]),_0x57ed55=this[_0x325ff1(0x154)]+_0x325ff1(0x181)+_0x240a44,_0x2bb7b3=this[_0x325ff1(0x13c)];while(this['running']){try{this['sseAbort']=new AbortController();let _0x104f94={'Accept':_0x325ff1(0x17e)};if(this[_0x325ff1(0x137)])_0x104f94[_0x325ff1(0x14c)]=_0x325ff1(0x176)+this[_0x325ff1(0x137)];let _0x1aea74=await fetch(_0x57ed55,{'headers':_0x104f94,'signal':this['sseAbort'][_0x325ff1(0x174)]});if(!_0x1aea74['ok']||!_0x1aea74[_0x325ff1(0x170)]){this[_0x325ff1(0x135)](_0x325ff1(0x125)+_0x1aea74[_0x325ff1(0x16e)]),await this['sleep'](_0x2bb7b3),_0x2bb7b3=Math[_0x325ff1(0x10f)](_0x2bb7b3*1.5,0xea60);continue;}_0x2bb7b3=this[_0x325ff1(0x13c)];let _0x3cf660=_0x1aea74['body'][_0x325ff1(0x165)](),_0x4e89c1=new TextDecoder(),_0x5f3421='';while(this[_0x325ff1(0x16c)]){let {done:_0x57e8ac,value:_0x35044b}=await _0x3cf660['read']();if(_0x57e8ac)break;_0x5f3421+=_0x4e89c1[_0x325ff1(0x109)](_0x35044b,{'stream':!0x0});let _0x388300=_0x5f3421[_0x325ff1(0x13b)]('\x0a');_0x5f3421=_0x388300[_0x325ff1(0x115)]()||'';for(let _0x214d4b of _0x388300){if(!_0x214d4b[_0x325ff1(0x11d)]('data:\x20'))continue;try{let _0x2a87a6=JSON[_0x325ff1(0x158)](_0x214d4b[_0x325ff1(0x14b)](0x6));if(_0x2a87a6['type']==='connected'){this[_0x325ff1(0x135)]('SSE\x20connected'),this['emit'](_0x325ff1(0x15b));continue;}if(_0x2a87a6[_0x325ff1(0x16a)]==='new_task'||_0x2a87a6[_0x325ff1(0x16a)]==='new_message'||_0x2a87a6[_0x325ff1(0x16a)]===_0x325ff1(0x15c))await this[_0x325ff1(0x112)]();}catch{}}}}catch(_0x5ca77c){if(_0x5ca77c[_0x325ff1(0x114)]===_0x325ff1(0x118))break;this[_0x325ff1(0x15e)](_0x325ff1(0x11a),_0x5ca77c),this['log'](_0x325ff1(0x136)+_0x5ca77c[_0x325ff1(0x15d)]);}if(this['running'])this[_0x325ff1(0x15e)](_0x325ff1(0x13d)),this[_0x325ff1(0x135)](_0x325ff1(0x182)+_0x2bb7b3/0x3e8+_0x325ff1(0x179)),await this[_0x325ff1(0x148)](_0x2bb7b3),_0x2bb7b3=Math[_0x325ff1(0x10f)](_0x2bb7b3*1.5,0xea60);}}async[a0_0x348570(0x112)](){const _0xbce9fd=a0_0x348570;try{let _0xc2b3e0=(await this[_0xbce9fd(0x13f)](_0xbce9fd(0x153),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x1d825e of _0xc2b3e0)await this['call'](_0xbce9fd(0x123),{'alias':this['alias'],'message_id':_0x1d825e['id']}),this[_0xbce9fd(0x135)]('←\x20'+_0x1d825e[_0xbce9fd(0x162)]+':\x20'+_0x1d825e[_0xbce9fd(0x161)][_0xbce9fd(0x14b)](0x0,0x3c)),this[_0xbce9fd(0x15e)]('task',_0x1d825e),this['emit']('message',_0x1d825e);}catch(_0x4375b3){this['log'](_0xbce9fd(0x160)+_0x4375b3[_0xbce9fd(0x15d)]);}}[a0_0x348570(0x148)](_0x80fb5b){return new Promise(_0x2d2a50=>setTimeout(_0x2d2a50,_0x80fb5b));}}function a0_0x5d04(){const _0x6b05a4=['registered','string','toString','error_message','send_failed','parentTaskId','CommHub\x20rejected\x20task','connect','215kFgBtO','log','SSE\x20error:\x20','token','1055384hOdVLt','heartbeatInterval','agent','split','reconnectDelay','disconnected','task.send.start','call','<unknown>','application/json','delivered','disconnect','send_rejected','2654avhsMN','duration_ms','abort','sleep','resumeId','\x20from=','slice','Authorization','tools/call',']\x20[commhub:','task.started','sseAbort','failed','371230KsNuua','get_inbox','url','lifecycle_tracking','completed','send','parse','mcp_http','idle','connected','broadcast','message','emit','sdk-','inbox\x20error:\x20','content','from_session','send_message','3350281qwmDCV','getReader','application/json,\x20text/event-stream','CommHub\x20response\x20omitted\x20task_id','alias','sdk','type','not_tracked','running','42OMgWlF','status','\x20to=','body','1301268atnmGO','replace','<pending>','signal','\x20transport=','Bearer\x20','task.send.failed','heartbeatTimer','s...','message_id','text','parent_task_id','2388DQkQFg','text/event-stream','3620gXoaUu','reply','/events/','SSE\x20reconnecting\x20in\x20','transport','decode','cwd','36536UbceqW','task.ack','normal','missing_task_id','min','27171ulAJUK','send_reply','processInbox','getAllStatus','name','pop','stringify','catch','AbortError','2.0','error','[commhub:task]\x20','now','startsWith','POST','task_id','get_all_status','toTimeString','report_status','ack_inbox','heartbeat\x20failed:\x20','SSE\x20failed:\x20','unknown\x20error','48MqKVbY','task.expired','connectSSE','\x20network_id=','from_alias'];a0_0x5d04=function(){return _0x6b05a4;};return a0_0x5d04();}var F=$;export{F as default,$ as CommHub};
1
+ function a0_0x2c82(_0x29e3b4,_0x50df15){_0x29e3b4=_0x29e3b4-0x16e;const _0x9a1373=a0_0x9a13();let _0x2c82be=_0x9a1373[_0x29e3b4];return _0x2c82be;}const a0_0x4bafa8=a0_0x2c82;(function(_0xd5fb87,_0x15a97d){const _0x2311d=a0_0x2c82,_0x3744a7=_0xd5fb87();while(!![]){try{const _0x1314e3=parseInt(_0x2311d(0x188))/0x1*(-parseInt(_0x2311d(0x1b5))/0x2)+-parseInt(_0x2311d(0x1ab))/0x3*(-parseInt(_0x2311d(0x1de))/0x4)+parseInt(_0x2311d(0x1bb))/0x5*(parseInt(_0x2311d(0x173))/0x6)+parseInt(_0x2311d(0x186))/0x7*(parseInt(_0x2311d(0x1d9))/0x8)+-parseInt(_0x2311d(0x1bd))/0x9+-parseInt(_0x2311d(0x1e5))/0xa*(-parseInt(_0x2311d(0x1d1))/0xb)+-parseInt(_0x2311d(0x1b6))/0xc*(-parseInt(_0x2311d(0x181))/0xd);if(_0x1314e3===_0x15a97d)break;else _0x3744a7['push'](_0x3744a7['shift']());}catch(_0x3381fa){_0x3744a7['push'](_0x3744a7['shift']());}}}(a0_0x9a13,0xb8152));import{EventEmitter as a0_0x59605c}from'events';import{hostname as a0_0x37c631}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x1bd959,_0x3fdeec)=>(_0x1bd959??_0x3fdeec)[a0_0x4bafa8(0x172)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x4bafa8(0x179)](0x0,0xf0);function N(_0x3f2a42){const _0x44a16d=a0_0x4bafa8;return(_0x3f2a42 instanceof Error?_0x3f2a42[_0x44a16d(0x1c7)]:String(_0x3f2a42??_0x44a16d(0x19e)))[_0x44a16d(0x172)](K,'[REDACTED]')['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x1d418a,_0x8245c2=process.env.ANET_TASK_TRACE_FORMAT===a0_0x4bafa8(0x197)){const _0x5d1a50=a0_0x4bafa8;if(_0x8245c2)return JSON[_0x5d1a50(0x199)](_0x1d418a);let _0x35c2ab=L(_0x1d418a[_0x5d1a50(0x18b)],_0x5d1a50(0x1ad)),_0x41d074=L(_0x1d418a['task_id'],_0x5d1a50(0x1e1)),_0x1d61e3=_0x1d418a[_0x5d1a50(0x1e6)]?_0x5d1a50(0x1e9)+_0x1d418a[_0x5d1a50(0x1e6)]+':'+(_0x1d418a['error_message']??''):'';return _0x5d1a50(0x18e)+_0x1d418a[_0x5d1a50(0x19b)]+'\x20from='+L(_0x1d418a[_0x5d1a50(0x189)],_0x5d1a50(0x19d))+'\x20to='+L(_0x1d418a[_0x5d1a50(0x16f)],_0x5d1a50(0x19d))+_0x5d1a50(0x175)+_0x41d074+_0x5d1a50(0x1af)+_0x35c2ab+_0x5d1a50(0x1a1)+L(_0x1d418a['network_id'],_0x5d1a50(0x19d))+_0x5d1a50(0x1c6)+_0x1d418a[_0x5d1a50(0x1a7)]+'\x20duration_ms='+_0x1d418a[_0x5d1a50(0x193)]+_0x5d1a50(0x1c9)+_0x1d418a[_0x5d1a50(0x1c5)]+_0x1d61e3;}function a0_0x9a13(){const _0x2830c5=['231GIglRz','sdk','4006mxQvkc','from_alias','signal','parent_task_id','not_tracked','delivered','[commhub:task]\x20','normal','task.replied','mcp_http','broadcast','duration_ms','networkId','connected','AbortError','json','task.send.delivered','stringify','failed','status','application/json,\x20text/event-stream','<unknown>','unknown\x20error','catch','messages','\x20network_id=','processInbox','task_id','lifecycleTracking','sleep','error','transport','task.ack','SSE\x20connected','decode','9789ulwsQJ','match','<missing>','send_task','\x20parent_task_id=','connectSSE','completed','resumeId','call','CommHub\x20response\x20omitted\x20task_id','654BYeAvX','24642444NdAWVf','task.expired','emit','task','text/event-stream','398060XSnUfF','content','11564136lebJaN','SSE\x20failed:\x20','send_reply','registered','send_failed','parse','cwd','alias','lifecycle_tracking','\x20transport=','message','idle','\x20lifecycle=','parentTaskId','send_message','pop','reconnectDelay','send','token','POST','82049eAlPEj','heartbeatInterval','text','tools/call','/mcp','send_rejected','heartbeat\x20failed:\x20','connect','72344QgloPw','disconnected','s...','startsWith','sseAbort','652CFlFdk','running','split','<pending>','url','new_message','inbox\x20error:\x20','410trUCSU','error_code','ack_inbox','SSE\x20reconnecting\x20in\x20','\x20error=','get_inbox','sdk-','to_alias','body','now','replace','12YSDbRp','getAllStatus','\x20task_id=','from_session','type','2.0','slice','Bearer\x20','heartbeatTimer','message_id','Authorization','string','disconnect','agent','13VlHEYb',']\x20[commhub:','log','task.send.failed','getReader'];a0_0x9a13=function(){return _0x2830c5;};return a0_0x9a13();}function U(_0x2ddd22){const _0x4d7772=a0_0x4bafa8;return{'event':{'sending':'task.send.start','delivered':_0x4d7772(0x198),'failed':_0x4d7772(0x184),'acked':_0x4d7772(0x1a8),'started':'task.started','replied':_0x4d7772(0x190),'expired':_0x4d7772(0x1b7)}[_0x2ddd22['status']],..._0x2ddd22};}function j(_0x285d05){const _0x48daf7=a0_0x4bafa8;let _0x4850f0=_0x285d05?.[_0x48daf7(0x1a3)]||_0x285d05?.[_0x48daf7(0x17c)]||_0x285d05?.['id'];if(_0x4850f0)return String(_0x4850f0);let _0x671a1d=_0x285d05?.['content']?.[0x0]?.[_0x48daf7(0x1d3)];if(typeof _0x671a1d!==_0x48daf7(0x17e))return null;try{let _0x252119=JSON[_0x48daf7(0x1c2)](_0x671a1d);return _0x252119?.['task_id']||_0x252119?.[_0x48daf7(0x17c)]||_0x252119?.['id']||null;}catch{return null;}}async function X(_0xbaaaaf,_0x22258e){const _0x2a03c7=a0_0x4bafa8;let _0x28ddf7=_0x22258e[_0x2a03c7(0x171)]??Date[_0x2a03c7(0x171)],_0x52105f=_0x28ddf7(),_0x29947=(_0x1527e3,_0x109547,_0x85e226,_0xfa6a56)=>{const _0x4e5c42=_0x2a03c7;_0x22258e[_0x4e5c42(0x183)](O(U({'from_alias':_0xbaaaaf['fromAlias'],'to_alias':_0xbaaaaf['toAlias'],'task_id':_0x109547,'parent_task_id':_0xbaaaaf[_0x4e5c42(0x1ca)],'network_id':_0xbaaaaf[_0x4e5c42(0x194)],'transport':_0xbaaaaf[_0x4e5c42(0x1a7)],'status':_0x1527e3,'duration_ms':_0x28ddf7()-_0x52105f,'lifecycle_tracking':_0xbaaaaf[_0x4e5c42(0x1a4)],..._0x85e226!==void 0x0?{'error_code':_0xfa6a56||_0x4e5c42(0x1c1),'error_message':N(_0x85e226)}:{}})));};_0x29947('sending',null);try{let _0x574cf5=await _0x22258e[_0x2a03c7(0x1ce)](),_0x4543e8=j(_0x574cf5);if(_0x4543e8)_0x29947(_0x2a03c7(0x18d),_0x4543e8);else{if(_0x574cf5?.['ok']===!0x1||_0x574cf5?.[_0x2a03c7(0x1a6)])_0x29947(_0x2a03c7(0x19a),_0x4543e8,_0x574cf5?.[_0x2a03c7(0x1a6)]||'CommHub\x20rejected\x20task',_0x2a03c7(0x1d6));else _0x29947(_0x2a03c7(0x19a),null,_0x2a03c7(0x1b4),'missing_task_id');}return _0x574cf5;}catch(_0x4612e8){throw _0x29947(_0x2a03c7(0x19a),null,_0x4612e8,'send_failed'),_0x4612e8;}}async function Y(_0x36c523,_0x8c14d5){const _0x55c4f9=a0_0x4bafa8;return X({'fromAlias':_0x36c523['fromAlias'],'toAlias':_0x36c523[_0x55c4f9(0x1c4)],'parentTaskId':_0x36c523[_0x55c4f9(0x1ca)]||null,'networkId':_0x36c523[_0x55c4f9(0x194)]||null,'transport':_0x55c4f9(0x191),'lifecycleTracking':_0x55c4f9(0x18c)},_0x8c14d5);}class $ extends a0_0x59605c{[a0_0x4bafa8(0x1e2)];['alias'];[a0_0x4bafa8(0x1cf)];[a0_0x4bafa8(0x180)];['resumeId'];['heartbeatInterval'];[a0_0x4bafa8(0x1cd)];[a0_0x4bafa8(0x17b)];[a0_0x4bafa8(0x1dd)];[a0_0x4bafa8(0x1df)]=!0x1;constructor(_0x5ec976){const _0x1ee2a3=a0_0x4bafa8;super();if(this[_0x1ee2a3(0x1e2)]=_0x5ec976[_0x1ee2a3(0x1e2)]['replace'](/\/$/,''),this['alias']=_0x5ec976[_0x1ee2a3(0x1c4)],this[_0x1ee2a3(0x1cf)]=_0x5ec976[_0x1ee2a3(0x1cf)],this[_0x1ee2a3(0x180)]=_0x5ec976[_0x1ee2a3(0x180)]||_0x1ee2a3(0x187),this[_0x1ee2a3(0x1b2)]=_0x1ee2a3(0x16e)+_0x5ec976[_0x1ee2a3(0x1c4)]+'-'+Date[_0x1ee2a3(0x171)]()['toString'](0x24),this['heartbeatInterval']=_0x5ec976[_0x1ee2a3(0x1d2)]??0x2bf20,this[_0x1ee2a3(0x1cd)]=_0x5ec976['reconnectDelay']??0xbb8,_0x5ec976['autoConnect']!==!0x1)this['connect']();}[a0_0x4bafa8(0x183)](_0x419303){const _0x18e13d=a0_0x4bafa8;console[_0x18e13d(0x183)]('['+new Date()['toTimeString']()[_0x18e13d(0x179)](0x0,0x8)+_0x18e13d(0x182)+this[_0x18e13d(0x1c4)]+']\x20'+_0x419303);}async[a0_0x4bafa8(0x1b3)](_0x150364,_0x11bcaa){const _0x3ac380=a0_0x4bafa8;let _0x3e2d13={'Content-Type':'application/json','Accept':_0x3ac380(0x19c)};if(this[_0x3ac380(0x1cf)])_0x3e2d13[_0x3ac380(0x17d)]=_0x3ac380(0x17a)+this[_0x3ac380(0x1cf)];let _0x4fe97d=await(await fetch(this[_0x3ac380(0x1e2)]+_0x3ac380(0x1d5),{'method':_0x3ac380(0x1d0),'headers':_0x3e2d13,'body':JSON[_0x3ac380(0x199)]({'jsonrpc':_0x3ac380(0x178),'id':Date['now'](),'method':_0x3ac380(0x1d4),'params':{'name':_0x150364,'arguments':_0x11bcaa}})}))[_0x3ac380(0x1d3)](),_0x1f00b2=_0x4fe97d[_0x3ac380(0x1ac)](/data: (.+)/),_0x2335f7=_0x1f00b2?JSON[_0x3ac380(0x1c2)](_0x1f00b2[0x1]):JSON[_0x3ac380(0x1c2)](_0x4fe97d),_0x2e277e=_0x2335f7?.['result']?.[_0x3ac380(0x1bc)]?.[0x0]?.[_0x3ac380(0x1d3)];return _0x2e277e?JSON['parse'](_0x2e277e):_0x2335f7;}async[a0_0x4bafa8(0x1d8)](){const _0x43b052=a0_0x4bafa8;if(this[_0x43b052(0x1df)])return;this[_0x43b052(0x1df)]=!0x0,await this['status'](_0x43b052(0x1c8)),this[_0x43b052(0x183)](_0x43b052(0x1c0)),this[_0x43b052(0x17b)]=setInterval(()=>{const _0x1ae2c3=_0x43b052;this[_0x1ae2c3(0x19b)](_0x1ae2c3(0x1c8))[_0x1ae2c3(0x19f)](_0x4f2af1=>this[_0x1ae2c3(0x183)](_0x1ae2c3(0x1d7)+_0x4f2af1[_0x1ae2c3(0x1c7)]));},this['heartbeatInterval']),this[_0x43b052(0x1b0)]();}async[a0_0x4bafa8(0x17f)](){const _0x36559f=a0_0x4bafa8;if(this[_0x36559f(0x1df)]=!0x1,this[_0x36559f(0x1dd)]?.['abort'](),this[_0x36559f(0x17b)])clearInterval(this[_0x36559f(0x17b)]);await this['status']('offline')['catch'](()=>{}),this[_0x36559f(0x183)]('disconnected');}async[a0_0x4bafa8(0x1ce)](_0x424513,_0x5aacf3,_0x33f0f0=a0_0x4bafa8(0x18f)){const _0x3a9e7a=a0_0x4bafa8;return Y({'alias':_0x424513,'fromAlias':this[_0x3a9e7a(0x1c4)]},{'log':_0x449526=>console[_0x3a9e7a(0x183)](_0x449526),'send':()=>this[_0x3a9e7a(0x1b3)](_0x3a9e7a(0x1ae),{'alias':_0x424513,'task':_0x5aacf3,'priority':_0x33f0f0,'from_session':this[_0x3a9e7a(0x1c4)]})});}async['message'](_0x5a6a47,_0xc86cf2){const _0x462919=a0_0x4bafa8;return this['call'](_0x462919(0x1cb),{'alias':_0x5a6a47,'message':_0xc86cf2,'from_session':this[_0x462919(0x1c4)]});}async['reply'](_0x1bbe0b,_0x4d35d8,_0x272584=a0_0x4bafa8(0x1b1)){const _0x14ed27=a0_0x4bafa8;return this[_0x14ed27(0x1b3)](_0x14ed27(0x1bf),{'in_reply_to':_0x1bbe0b,'text':_0x4d35d8,'status':_0x272584});}async[a0_0x4bafa8(0x19b)](_0x1eb430,_0x4d4f6a){const _0x59fce4=a0_0x4bafa8;return this[_0x59fce4(0x1b3)]('report_status',{'resume_id':this['resumeId'],'alias':this[_0x59fce4(0x1c4)],'status':_0x1eb430,'server':a0_0x37c631(),'hostname':a0_0x37c631(),'agent':this[_0x59fce4(0x180)],'project_dir':process[_0x59fce4(0x1c3)](),..._0x4d4f6a});}async[a0_0x4bafa8(0x174)](){const _0x4ae976=a0_0x4bafa8;return this[_0x4ae976(0x1b3)]('get_all_status',{});}async[a0_0x4bafa8(0x192)](_0x13adad,_0x318360){const _0x140c4=a0_0x4bafa8;return this[_0x140c4(0x1b3)](_0x140c4(0x192),{'message':_0x13adad,'filter_server':_0x318360?.['server'],'filter_status':_0x318360?.[_0x140c4(0x19b)]});}async[a0_0x4bafa8(0x1b0)](){const _0x533a69=a0_0x4bafa8;let _0x284025=encodeURIComponent(this[_0x533a69(0x1c4)]),_0x2f5e88=this[_0x533a69(0x1e2)]+'/events/'+_0x284025,_0xe3b1fd=this[_0x533a69(0x1cd)];while(this[_0x533a69(0x1df)]){try{this[_0x533a69(0x1dd)]=new AbortController();let _0x2fde69={'Accept':_0x533a69(0x1ba)};if(this[_0x533a69(0x1cf)])_0x2fde69[_0x533a69(0x17d)]=_0x533a69(0x17a)+this[_0x533a69(0x1cf)];let _0x379b3d=await fetch(_0x2f5e88,{'headers':_0x2fde69,'signal':this[_0x533a69(0x1dd)][_0x533a69(0x18a)]});if(!_0x379b3d['ok']||!_0x379b3d['body']){this[_0x533a69(0x183)](_0x533a69(0x1be)+_0x379b3d[_0x533a69(0x19b)]),await this['sleep'](_0xe3b1fd),_0xe3b1fd=Math['min'](_0xe3b1fd*1.5,0xea60);continue;}_0xe3b1fd=this['reconnectDelay'];let _0x27b566=_0x379b3d[_0x533a69(0x170)][_0x533a69(0x185)](),_0x434fcd=new TextDecoder(),_0x58c9b5='';while(this[_0x533a69(0x1df)]){let {done:_0x46c981,value:_0x549e43}=await _0x27b566['read']();if(_0x46c981)break;_0x58c9b5+=_0x434fcd[_0x533a69(0x1aa)](_0x549e43,{'stream':!0x0});let _0x171388=_0x58c9b5[_0x533a69(0x1e0)]('\x0a');_0x58c9b5=_0x171388[_0x533a69(0x1cc)]()||'';for(let _0xe1fa20 of _0x171388){if(!_0xe1fa20[_0x533a69(0x1dc)]('data:\x20'))continue;try{let _0x4567f1=JSON['parse'](_0xe1fa20['slice'](0x6));if(_0x4567f1[_0x533a69(0x177)]===_0x533a69(0x195)){this[_0x533a69(0x183)](_0x533a69(0x1a9)),this[_0x533a69(0x1b8)](_0x533a69(0x195));continue;}if(_0x4567f1[_0x533a69(0x177)]==='new_task'||_0x4567f1['type']===_0x533a69(0x1e3)||_0x4567f1[_0x533a69(0x177)]==='broadcast')await this[_0x533a69(0x1a2)]();}catch{}}}}catch(_0x14be2b){if(_0x14be2b['name']===_0x533a69(0x196))break;this[_0x533a69(0x1b8)](_0x533a69(0x1a6),_0x14be2b),this['log']('SSE\x20error:\x20'+_0x14be2b[_0x533a69(0x1c7)]);}if(this['running'])this['emit'](_0x533a69(0x1da)),this[_0x533a69(0x183)](_0x533a69(0x1e8)+_0xe3b1fd/0x3e8+_0x533a69(0x1db)),await this['sleep'](_0xe3b1fd),_0xe3b1fd=Math['min'](_0xe3b1fd*1.5,0xea60);}}async[a0_0x4bafa8(0x1a2)](){const _0x4efed8=a0_0x4bafa8;try{let _0x2bbef4=(await this['call'](_0x4efed8(0x1ea),{'alias':this[_0x4efed8(0x1c4)],'limit':0xa}))?.[_0x4efed8(0x1a0)]||[];for(let _0x29661c of _0x2bbef4)await this[_0x4efed8(0x1b3)](_0x4efed8(0x1e7),{'alias':this[_0x4efed8(0x1c4)],'message_id':_0x29661c['id']}),this[_0x4efed8(0x183)]('←\x20'+_0x29661c[_0x4efed8(0x176)]+':\x20'+_0x29661c['content'][_0x4efed8(0x179)](0x0,0x3c)),this[_0x4efed8(0x1b8)](_0x4efed8(0x1b9),_0x29661c),this[_0x4efed8(0x1b8)]('message',_0x29661c);}catch(_0xd0a5cc){this[_0x4efed8(0x183)](_0x4efed8(0x1e4)+_0xd0a5cc[_0x4efed8(0x1c7)]);}}[a0_0x4bafa8(0x1a5)](_0xfcde18){return new Promise(_0x507b15=>setTimeout(_0x507b15,_0xfcde18));}}var F=$;export{F as default,$ as CommHub};
@@ -0,0 +1,20 @@
1
+ export interface InboxPage<T> {
2
+ ok?: boolean;
3
+ messages?: T[];
4
+ }
5
+ export interface DrainOptions<T extends {
6
+ id: string;
7
+ }> {
8
+ fetchPage: (limit: number) => Promise<InboxPage<T> | undefined | null>;
9
+ handle: (msg: T) => Promise<void>;
10
+ pageSize?: number;
11
+ maxPages?: number;
12
+ }
13
+ export interface DrainResult {
14
+ delivered: number;
15
+ pages: number;
16
+ stoppedBy: "empty" | "short-page" | "max-pages" | "no-progress" | "fetch-error";
17
+ }
18
+ export declare function drainInbox<T extends {
19
+ id: string;
20
+ }>(opts: DrainOptions<T>): Promise<DrainResult>;