@sleep2agi/agent-network 2.3.0-preview.221 → 2.3.0-preview.223
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_0x369c55=a0_0x1894;function a0_0x1ce5(){const _0x4de065=['type','tools/call','registered','task.replied','toAlias','send_reply','failed','\x20error=','toTimeString','resumeId','emit','<pending>','task.send.failed','catch','/events/','error_message','lifecycle_tracking','SSE\x20reconnecting\x20in\x20','SSE\x20failed:\x20','split','s...','from_session','decode','replace','\x20duration_ms=','get_inbox','send_rejected','cwd','running','\x20transport=','heartbeatTimer','disconnected','delivered','to_alias','send_failed','idle','unknown\x20error','Bearer\x20','abort','error','min','sleep','alias','2.0','<missing>','fromAlias','new_task','1146491spSsMz','Authorization','task.expired','signal','name','autoConnect','sdk','startsWith','2UysXkK','\x20from=','POST','CommHub\x20rejected\x20task','mcp_http','agent','parse','result','parentTaskId','text','disconnect','heartbeatInterval','not_tracked','task.ack','\x20network_id=','offline',']\x20[commhub:','connect','1684884TnwbSi','report_status','read','SSE\x20connected','<unknown>','task','pop','network_id','3897180OZOHiL','application/json,\x20text/event-stream','reconnectDelay','1814620aVkolM','transport','message_id','status','sdk-','connectSSE','call','task.send.delivered','processInbox','broadcast','[REDACTED]','stringify','server','duration_ms','slice','\x20task_id=','application/json','send_task','missing_task_id','content','task_id','ack_inbox','CommHub\x20response\x20omitted\x20task_id','25116784MtIomv','12965flHsMN','inbox\x20error:\x20','message','send','get_all_status','token','from_alias','task.send.start','text/event-stream','body','8qsckqp','connected','log','3684KRooau','completed','normal','10917BUvHWO','AbortError','url','sseAbort','/mcp','\x20lifecycle=','now','data:\x20','3528YiQQGK','sending'];a0_0x1ce5=function(){return _0x4de065;};return a0_0x1ce5();}(function(_0x1998f7,_0x28fe99){const _0x4411ea=a0_0x1894,_0x1605aa=_0x1998f7();while(!![]){try{const _0x589a91=-parseInt(_0x4411ea(0x15c))/0x1*(parseInt(_0x4411ea(0x164))/0x2)+parseInt(_0x4411ea(0x176))/0x3*(parseInt(_0x4411ea(0x1a3))/0x4)+parseInt(_0x4411ea(0x199))/0x5*(-parseInt(_0x4411ea(0x1a6))/0x6)+parseInt(_0x4411ea(0x17e))/0x7+-parseInt(_0x4411ea(0x1b1))/0x8*(parseInt(_0x4411ea(0x1a9))/0x9)+parseInt(_0x4411ea(0x181))/0xa+parseInt(_0x4411ea(0x198))/0xb;if(_0x589a91===_0x28fe99)break;else _0x1605aa['push'](_0x1605aa['shift']());}catch(_0x2fa8d9){_0x1605aa['push'](_0x1605aa['shift']());}}}(a0_0x1ce5,0xd4b6c));import{EventEmitter as a0_0x353cf1}from'events';import{hostname as a0_0x33db31}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x1c2e75,_0xec0c3)=>(_0x1c2e75??_0xec0c3)[a0_0x369c55(0x144)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x369c55(0x18f)](0x0,0xf0);function N(_0x33cd37){const _0x2bc6a1=a0_0x369c55;return(_0x33cd37 instanceof Error?_0x33cd37['message']:String(_0x33cd37??_0x2bc6a1(0x151)))['replace'](K,_0x2bc6a1(0x18b))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x147432,_0x293380=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x13c9f9=a0_0x369c55;if(_0x293380)return JSON[_0x13c9f9(0x18c)](_0x147432);let _0x527060=L(_0x147432['parent_task_id'],_0x13c9f9(0x159)),_0x5ee430=L(_0x147432[_0x13c9f9(0x195)],_0x13c9f9(0x1be)),_0x17626a=_0x147432['error_code']?_0x13c9f9(0x1ba)+_0x147432['error_code']+':'+(_0x147432[_0x13c9f9(0x1c2)]??''):'';return'[commhub:task]\x20'+_0x147432[_0x13c9f9(0x184)]+_0x13c9f9(0x165)+L(_0x147432[_0x13c9f9(0x19f)],_0x13c9f9(0x17a))+'\x20to='+L(_0x147432[_0x13c9f9(0x14e)],_0x13c9f9(0x17a))+_0x13c9f9(0x190)+_0x5ee430+'\x20parent_task_id='+_0x527060+_0x13c9f9(0x172)+L(_0x147432[_0x13c9f9(0x17d)],_0x13c9f9(0x17a))+_0x13c9f9(0x14a)+_0x147432[_0x13c9f9(0x182)]+_0x13c9f9(0x145)+_0x147432[_0x13c9f9(0x18e)]+_0x13c9f9(0x1ae)+_0x147432[_0x13c9f9(0x1c3)]+_0x17626a;}function a0_0x1894(_0xf7e15e,_0x43fd27){_0xf7e15e=_0xf7e15e-0x13f;const _0x1ce5d2=a0_0x1ce5();let _0x18949b=_0x1ce5d2[_0xf7e15e];return _0x18949b;}function U(_0x39aefd){const _0xec4a2e=a0_0x369c55;return{'event':{'sending':_0xec4a2e(0x1a0),'delivered':_0xec4a2e(0x188),'failed':_0xec4a2e(0x1bf),'acked':_0xec4a2e(0x171),'started':'task.started','replied':_0xec4a2e(0x1b6),'expired':_0xec4a2e(0x15e)}[_0x39aefd['status']],..._0x39aefd};}function j(_0x4c3896){const _0x2d3b64=a0_0x369c55;let _0x128dd6=_0x4c3896?.['task_id']||_0x4c3896?.[_0x2d3b64(0x183)]||_0x4c3896?.['id'];if(_0x128dd6)return String(_0x128dd6);let _0x4aab34=_0x4c3896?.[_0x2d3b64(0x194)]?.[0x0]?.[_0x2d3b64(0x16d)];if(typeof _0x4aab34!=='string')return null;try{let _0x164801=JSON[_0x2d3b64(0x16a)](_0x4aab34);return _0x164801?.[_0x2d3b64(0x195)]||_0x164801?.[_0x2d3b64(0x183)]||_0x164801?.['id']||null;}catch{return null;}}async function X(_0x4615ed,_0x1f2bbd){const _0x6656ce=a0_0x369c55;let _0x177078=_0x1f2bbd['now']??Date[_0x6656ce(0x1af)],_0x19ae28=_0x177078(),_0x297b6e=(_0x48576c,_0x1499a2,_0x4060d6,_0x312dfe)=>{const _0x17fe2e=_0x6656ce;_0x1f2bbd[_0x17fe2e(0x1a5)](O(U({'from_alias':_0x4615ed[_0x17fe2e(0x15a)],'to_alias':_0x4615ed[_0x17fe2e(0x1b7)],'task_id':_0x1499a2,'parent_task_id':_0x4615ed[_0x17fe2e(0x16c)],'network_id':_0x4615ed['networkId'],'transport':_0x4615ed[_0x17fe2e(0x182)],'status':_0x48576c,'duration_ms':_0x177078()-_0x19ae28,'lifecycle_tracking':_0x4615ed['lifecycleTracking'],..._0x4060d6!==void 0x0?{'error_code':_0x312dfe||'send_failed','error_message':N(_0x4060d6)}:{}})));};_0x297b6e(_0x6656ce(0x1b2),null);try{let _0x1df06f=await _0x1f2bbd[_0x6656ce(0x19c)](),_0x2855fd=j(_0x1df06f);if(_0x2855fd)_0x297b6e(_0x6656ce(0x14d),_0x2855fd);else{if(_0x1df06f?.['ok']===!0x1||_0x1df06f?.[_0x6656ce(0x154)])_0x297b6e(_0x6656ce(0x1b9),_0x2855fd,_0x1df06f?.[_0x6656ce(0x154)]||_0x6656ce(0x167),_0x6656ce(0x147));else _0x297b6e('failed',null,_0x6656ce(0x197),_0x6656ce(0x193));}return _0x1df06f;}catch(_0x84c577){throw _0x297b6e(_0x6656ce(0x1b9),null,_0x84c577,_0x6656ce(0x14f)),_0x84c577;}}async function Y(_0x27e2f2,_0x17c6dc){const _0x220bb7=a0_0x369c55;return X({'fromAlias':_0x27e2f2['fromAlias'],'toAlias':_0x27e2f2[_0x220bb7(0x157)],'parentTaskId':_0x27e2f2['parentTaskId']||null,'networkId':_0x27e2f2['networkId']||null,'transport':_0x220bb7(0x168),'lifecycleTracking':_0x220bb7(0x170)},_0x17c6dc);}class $ extends a0_0x353cf1{['url'];[a0_0x369c55(0x157)];['token'];['agent'];[a0_0x369c55(0x1bc)];[a0_0x369c55(0x16f)];[a0_0x369c55(0x180)];[a0_0x369c55(0x14b)];[a0_0x369c55(0x1ac)];[a0_0x369c55(0x149)]=!0x1;constructor(_0x1e4ff6){const _0x4f4e07=a0_0x369c55;super();if(this['url']=_0x1e4ff6[_0x4f4e07(0x1ab)]['replace'](/\/$/,''),this[_0x4f4e07(0x157)]=_0x1e4ff6['alias'],this['token']=_0x1e4ff6['token'],this[_0x4f4e07(0x169)]=_0x1e4ff6[_0x4f4e07(0x169)]||_0x4f4e07(0x162),this['resumeId']=_0x4f4e07(0x185)+_0x1e4ff6[_0x4f4e07(0x157)]+'-'+Date[_0x4f4e07(0x1af)]()['toString'](0x24),this[_0x4f4e07(0x16f)]=_0x1e4ff6[_0x4f4e07(0x16f)]??0x2bf20,this[_0x4f4e07(0x180)]=_0x1e4ff6['reconnectDelay']??0xbb8,_0x1e4ff6[_0x4f4e07(0x161)]!==!0x1)this[_0x4f4e07(0x175)]();}[a0_0x369c55(0x1a5)](_0x3df325){const _0x109527=a0_0x369c55;console['log']('['+new Date()[_0x109527(0x1bb)]()[_0x109527(0x18f)](0x0,0x8)+_0x109527(0x174)+this[_0x109527(0x157)]+']\x20'+_0x3df325);}async[a0_0x369c55(0x187)](_0x5579a3,_0x2f63a0){const _0x32d644=a0_0x369c55;let _0x47d394={'Content-Type':_0x32d644(0x191),'Accept':_0x32d644(0x17f)};if(this[_0x32d644(0x19e)])_0x47d394[_0x32d644(0x15d)]='Bearer\x20'+this[_0x32d644(0x19e)];let _0x492bcb=await(await fetch(this[_0x32d644(0x1ab)]+_0x32d644(0x1ad),{'method':_0x32d644(0x166),'headers':_0x47d394,'body':JSON['stringify']({'jsonrpc':_0x32d644(0x158),'id':Date[_0x32d644(0x1af)](),'method':_0x32d644(0x1b4),'params':{'name':_0x5579a3,'arguments':_0x2f63a0}})}))[_0x32d644(0x16d)](),_0x5f532f=_0x492bcb['match'](/data: (.+)/),_0x3b5982=_0x5f532f?JSON[_0x32d644(0x16a)](_0x5f532f[0x1]):JSON[_0x32d644(0x16a)](_0x492bcb),_0x23cc65=_0x3b5982?.[_0x32d644(0x16b)]?.[_0x32d644(0x194)]?.[0x0]?.['text'];return _0x23cc65?JSON[_0x32d644(0x16a)](_0x23cc65):_0x3b5982;}async[a0_0x369c55(0x175)](){const _0x1dbd3e=a0_0x369c55;if(this['running'])return;this['running']=!0x0,await this[_0x1dbd3e(0x184)](_0x1dbd3e(0x150)),this['log'](_0x1dbd3e(0x1b5)),this[_0x1dbd3e(0x14b)]=setInterval(()=>{const _0x186975=_0x1dbd3e;this['status']('idle')[_0x186975(0x1c0)](_0x5dae91=>this[_0x186975(0x1a5)]('heartbeat\x20failed:\x20'+_0x5dae91['message']));},this[_0x1dbd3e(0x16f)]),this[_0x1dbd3e(0x186)]();}async[a0_0x369c55(0x16e)](){const _0x5cac9f=a0_0x369c55;if(this[_0x5cac9f(0x149)]=!0x1,this[_0x5cac9f(0x1ac)]?.[_0x5cac9f(0x153)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0x5cac9f(0x184)](_0x5cac9f(0x173))[_0x5cac9f(0x1c0)](()=>{}),this[_0x5cac9f(0x1a5)](_0x5cac9f(0x14c));}async[a0_0x369c55(0x19c)](_0x5b4722,_0x498bca,_0x42f952=a0_0x369c55(0x1a8)){const _0x45ea82=a0_0x369c55;return Y({'alias':_0x5b4722,'fromAlias':this[_0x45ea82(0x157)]},{'log':_0x2a52fb=>console['log'](_0x2a52fb),'send':()=>this['call'](_0x45ea82(0x192),{'alias':_0x5b4722,'task':_0x498bca,'priority':_0x42f952,'from_session':this[_0x45ea82(0x157)]})});}async[a0_0x369c55(0x19b)](_0x1c5b6f,_0x529a5d){return this['call']('send_message',{'alias':_0x1c5b6f,'message':_0x529a5d,'from_session':this['alias']});}async['reply'](_0x1bec36,_0x1c15e,_0x583f2f=a0_0x369c55(0x1a7)){const _0x4423fa=a0_0x369c55;return this[_0x4423fa(0x187)](_0x4423fa(0x1b8),{'in_reply_to':_0x1bec36,'text':_0x1c15e,'status':_0x583f2f});}async[a0_0x369c55(0x184)](_0x24fe03,_0x3df37f){const _0x5901c5=a0_0x369c55;return this[_0x5901c5(0x187)](_0x5901c5(0x177),{'resume_id':this[_0x5901c5(0x1bc)],'alias':this[_0x5901c5(0x157)],'status':_0x24fe03,'server':a0_0x33db31(),'hostname':a0_0x33db31(),'agent':this['agent'],'project_dir':process[_0x5901c5(0x148)](),..._0x3df37f});}async['getAllStatus'](){const _0x2ed14d=a0_0x369c55;return this['call'](_0x2ed14d(0x19d),{});}async[a0_0x369c55(0x18a)](_0x117ff1,_0x4c08d8){const _0x2920c9=a0_0x369c55;return this[_0x2920c9(0x187)](_0x2920c9(0x18a),{'message':_0x117ff1,'filter_server':_0x4c08d8?.[_0x2920c9(0x18d)],'filter_status':_0x4c08d8?.['status']});}async['connectSSE'](){const _0x3317a1=a0_0x369c55;let _0x5511aa=encodeURIComponent(this[_0x3317a1(0x157)]),_0x2780f3=this['url']+_0x3317a1(0x1c1)+_0x5511aa,_0x4e058d=this[_0x3317a1(0x180)];while(this[_0x3317a1(0x149)]){try{this[_0x3317a1(0x1ac)]=new AbortController();let _0xc116a6={'Accept':_0x3317a1(0x1a1)};if(this[_0x3317a1(0x19e)])_0xc116a6[_0x3317a1(0x15d)]=_0x3317a1(0x152)+this['token'];let _0x568372=await fetch(_0x2780f3,{'headers':_0xc116a6,'signal':this[_0x3317a1(0x1ac)][_0x3317a1(0x15f)]});if(!_0x568372['ok']||!_0x568372[_0x3317a1(0x1a2)]){this['log'](_0x3317a1(0x13f)+_0x568372[_0x3317a1(0x184)]),await this['sleep'](_0x4e058d),_0x4e058d=Math[_0x3317a1(0x155)](_0x4e058d*1.5,0xea60);continue;}_0x4e058d=this[_0x3317a1(0x180)];let _0x5a7521=_0x568372[_0x3317a1(0x1a2)]['getReader'](),_0x1d4ff6=new TextDecoder(),_0x36ecdd='';while(this[_0x3317a1(0x149)]){let {done:_0x12555e,value:_0x42e5bf}=await _0x5a7521[_0x3317a1(0x178)]();if(_0x12555e)break;_0x36ecdd+=_0x1d4ff6[_0x3317a1(0x143)](_0x42e5bf,{'stream':!0x0});let _0x508b3c=_0x36ecdd[_0x3317a1(0x140)]('\x0a');_0x36ecdd=_0x508b3c[_0x3317a1(0x17c)]()||'';for(let _0x4d8682 of _0x508b3c){if(!_0x4d8682[_0x3317a1(0x163)](_0x3317a1(0x1b0)))continue;try{let _0x1627e6=JSON[_0x3317a1(0x16a)](_0x4d8682['slice'](0x6));if(_0x1627e6[_0x3317a1(0x1b3)]===_0x3317a1(0x1a4)){this['log'](_0x3317a1(0x179)),this[_0x3317a1(0x1bd)](_0x3317a1(0x1a4));continue;}if(_0x1627e6[_0x3317a1(0x1b3)]===_0x3317a1(0x15b)||_0x1627e6['type']==='new_message'||_0x1627e6[_0x3317a1(0x1b3)]===_0x3317a1(0x18a))await this[_0x3317a1(0x189)]();}catch{}}}}catch(_0x58ebda){if(_0x58ebda[_0x3317a1(0x160)]===_0x3317a1(0x1aa))break;this[_0x3317a1(0x1bd)]('error',_0x58ebda),this[_0x3317a1(0x1a5)]('SSE\x20error:\x20'+_0x58ebda['message']);}if(this[_0x3317a1(0x149)])this[_0x3317a1(0x1bd)](_0x3317a1(0x14c)),this[_0x3317a1(0x1a5)](_0x3317a1(0x1c4)+_0x4e058d/0x3e8+_0x3317a1(0x141)),await this[_0x3317a1(0x156)](_0x4e058d),_0x4e058d=Math['min'](_0x4e058d*1.5,0xea60);}}async[a0_0x369c55(0x189)](){const _0x117ce0=a0_0x369c55;try{let _0x38c19a=(await this[_0x117ce0(0x187)](_0x117ce0(0x146),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x58678b of _0x38c19a)await this[_0x117ce0(0x187)](_0x117ce0(0x196),{'alias':this[_0x117ce0(0x157)],'message_id':_0x58678b['id']}),this[_0x117ce0(0x1a5)]('←\x20'+_0x58678b[_0x117ce0(0x142)]+':\x20'+_0x58678b[_0x117ce0(0x194)]['slice'](0x0,0x3c)),this[_0x117ce0(0x1bd)](_0x117ce0(0x17b),_0x58678b),this[_0x117ce0(0x1bd)](_0x117ce0(0x19b),_0x58678b);}catch(_0x3cf619){this[_0x117ce0(0x1a5)](_0x117ce0(0x19a)+_0x3cf619[_0x117ce0(0x19b)]);}}[a0_0x369c55(0x156)](_0x3d13c4){return new Promise(_0x177aed=>setTimeout(_0x177aed,_0x3d13c4));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x2e14af=a0_0x2b59;(function(_0x2ddf19,_0x3623a7){const _0x7b2d53=a0_0x2b59,_0xbb6f76=_0x2ddf19();while(!![]){try{const _0xede882=-parseInt(_0x7b2d53(0x1a4))/0x1*(parseInt(_0x7b2d53(0x1a8))/0x2)+-parseInt(_0x7b2d53(0x1b7))/0x3*(parseInt(_0x7b2d53(0x1ad))/0x4)+-parseInt(_0x7b2d53(0x196))/0x5*(parseInt(_0x7b2d53(0x1d6))/0x6)+-parseInt(_0x7b2d53(0x1be))/0x7*(-parseInt(_0x7b2d53(0x1dc))/0x8)+parseInt(_0x7b2d53(0x1ca))/0x9*(parseInt(_0x7b2d53(0x1df))/0xa)+parseInt(_0x7b2d53(0x17c))/0xb*(parseInt(_0x7b2d53(0x16a))/0xc)+-parseInt(_0x7b2d53(0x1d9))/0xd*(parseInt(_0x7b2d53(0x18d))/0xe);if(_0xede882===_0x3623a7)break;else _0xbb6f76['push'](_0xbb6f76['shift']());}catch(_0x4b1da2){_0xbb6f76['push'](_0xbb6f76['shift']());}}}(a0_0x588d,0xa28df));function a0_0x2b59(_0x1e90bc,_0x30e918){_0x1e90bc=_0x1e90bc-0x163;const _0x588d10=a0_0x588d();let _0x2b59d6=_0x588d10[_0x1e90bc];return _0x2b59d6;}import{EventEmitter as a0_0x3c2b07}from'events';import{hostname as a0_0xe61605}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2f015c,_0x26a9ed)=>(_0x2f015c??_0x26a9ed)[a0_0x2e14af(0x176)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x2e14af(0x1b6)](0x0,0xf0);function N(_0x5ea73a){const _0x38ae26=a0_0x2e14af;return(_0x5ea73a instanceof Error?_0x5ea73a[_0x38ae26(0x1c8)]:String(_0x5ea73a??'unknown\x20error'))[_0x38ae26(0x176)](K,'[REDACTED]')[_0x38ae26(0x176)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x38ae26(0x1b6)](0x0,0xf0);}function O(_0x1320ca,_0x4024c3=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2e14af(0x181)){const _0x5829ae=a0_0x2e14af;if(_0x4024c3)return JSON['stringify'](_0x1320ca);let _0x2b3590=L(_0x1320ca[_0x5829ae(0x1c2)],'<missing>'),_0x3b46ed=L(_0x1320ca[_0x5829ae(0x16e)],_0x5829ae(0x19b)),_0x422d62=_0x1320ca[_0x5829ae(0x1c1)]?_0x5829ae(0x1bb)+_0x1320ca[_0x5829ae(0x1c1)]+':'+(_0x1320ca['error_message']??''):'';return'[commhub:task]\x20'+_0x1320ca[_0x5829ae(0x179)]+_0x5829ae(0x182)+L(_0x1320ca['from_alias'],_0x5829ae(0x1b1))+_0x5829ae(0x1db)+L(_0x1320ca[_0x5829ae(0x1cc)],_0x5829ae(0x1b1))+_0x5829ae(0x1a3)+_0x3b46ed+_0x5829ae(0x1b3)+_0x2b3590+'\x20network_id='+L(_0x1320ca[_0x5829ae(0x1e0)],_0x5829ae(0x1b1))+'\x20transport='+_0x1320ca[_0x5829ae(0x17f)]+_0x5829ae(0x1e1)+_0x1320ca[_0x5829ae(0x177)]+_0x5829ae(0x190)+_0x1320ca['lifecycle_tracking']+_0x422d62;}function U(_0x344a7a){const _0xcdf15=a0_0x2e14af;return{'event':{'sending':_0xcdf15(0x16f),'delivered':_0xcdf15(0x1b5),'failed':_0xcdf15(0x191),'acked':'task.ack','started':_0xcdf15(0x186),'replied':_0xcdf15(0x1c0),'expired':_0xcdf15(0x18f)}[_0x344a7a[_0xcdf15(0x179)]],..._0x344a7a};}function j(_0x32aeac){const _0x881e1d=a0_0x2e14af;let _0x41a2a4=_0x32aeac?.[_0x881e1d(0x16e)]||_0x32aeac?.[_0x881e1d(0x18b)]||_0x32aeac?.['id'];if(_0x41a2a4)return String(_0x41a2a4);let _0x482d2a=_0x32aeac?.[_0x881e1d(0x1a6)]?.[0x0]?.['text'];if(typeof _0x482d2a!==_0x881e1d(0x1e2))return null;try{let _0x58cb41=JSON[_0x881e1d(0x19f)](_0x482d2a);return _0x58cb41?.[_0x881e1d(0x16e)]||_0x58cb41?.[_0x881e1d(0x18b)]||_0x58cb41?.['id']||null;}catch{return null;}}async function X(_0x4c8cf3,_0x175df3){const _0x226d98=a0_0x2e14af;let _0x11680a=_0x175df3['now']??Date['now'],_0x2839c1=_0x11680a(),_0x3d61ea=(_0x329a9b,_0x3c41be,_0x397543,_0x172f8d)=>{const _0x36ba59=a0_0x2b59;_0x175df3[_0x36ba59(0x1de)](O(U({'from_alias':_0x4c8cf3[_0x36ba59(0x1cd)],'to_alias':_0x4c8cf3[_0x36ba59(0x1b0)],'task_id':_0x3c41be,'parent_task_id':_0x4c8cf3[_0x36ba59(0x19e)],'network_id':_0x4c8cf3[_0x36ba59(0x1d7)],'transport':_0x4c8cf3[_0x36ba59(0x17f)],'status':_0x329a9b,'duration_ms':_0x11680a()-_0x2839c1,'lifecycle_tracking':_0x4c8cf3[_0x36ba59(0x1a9)],..._0x397543!==void 0x0?{'error_code':_0x172f8d||_0x36ba59(0x17d),'error_message':N(_0x397543)}:{}})));};_0x3d61ea('sending',null);try{let _0x4b9587=await _0x175df3[_0x226d98(0x163)](),_0x515124=j(_0x4b9587);if(_0x515124)_0x3d61ea(_0x226d98(0x194),_0x515124);else{if(_0x4b9587?.['ok']===!0x1||_0x4b9587?.['error'])_0x3d61ea('failed',_0x515124,_0x4b9587?.[_0x226d98(0x17a)]||_0x226d98(0x1b4),_0x226d98(0x165));else _0x3d61ea(_0x226d98(0x189),null,_0x226d98(0x1b2),'missing_task_id');}return _0x4b9587;}catch(_0x44b8f8){throw _0x3d61ea(_0x226d98(0x189),null,_0x44b8f8,_0x226d98(0x17d)),_0x44b8f8;}}async function Y(_0x33a519,_0x106714){const _0x3bb123=a0_0x2e14af;return X({'fromAlias':_0x33a519['fromAlias'],'toAlias':_0x33a519[_0x3bb123(0x1bc)],'parentTaskId':_0x33a519[_0x3bb123(0x19e)]||null,'networkId':_0x33a519[_0x3bb123(0x1d7)]||null,'transport':_0x3bb123(0x1ba),'lifecycleTracking':_0x3bb123(0x1a0)},_0x106714);}class $ extends a0_0x3c2b07{[a0_0x2e14af(0x199)];[a0_0x2e14af(0x1bc)];[a0_0x2e14af(0x1c6)];[a0_0x2e14af(0x1d1)];[a0_0x2e14af(0x1ce)];[a0_0x2e14af(0x17b)];[a0_0x2e14af(0x178)];[a0_0x2e14af(0x18e)];[a0_0x2e14af(0x1d3)];[a0_0x2e14af(0x19d)]=!0x1;constructor(_0x546504){const _0x50941a=a0_0x2e14af;super();if(this[_0x50941a(0x199)]=_0x546504[_0x50941a(0x199)]['replace'](/\/$/,''),this['alias']=_0x546504['alias'],this[_0x50941a(0x1c6)]=_0x546504[_0x50941a(0x1c6)],this['agent']=_0x546504[_0x50941a(0x1d1)]||_0x50941a(0x1d8),this[_0x50941a(0x1ce)]=_0x50941a(0x1ae)+_0x546504[_0x50941a(0x1bc)]+'-'+Date[_0x50941a(0x1b9)]()[_0x50941a(0x180)](0x24),this[_0x50941a(0x17b)]=_0x546504[_0x50941a(0x17b)]??0x2bf20,this[_0x50941a(0x178)]=_0x546504['reconnectDelay']??0xbb8,_0x546504[_0x50941a(0x175)]!==!0x1)this['connect']();}[a0_0x2e14af(0x1de)](_0x4d7637){const _0x2d1c3c=a0_0x2e14af;console[_0x2d1c3c(0x1de)]('['+new Date()[_0x2d1c3c(0x16d)]()[_0x2d1c3c(0x1b6)](0x0,0x8)+']\x20[commhub:'+this[_0x2d1c3c(0x1bc)]+']\x20'+_0x4d7637);}async[a0_0x2e14af(0x19c)](_0x58aab2,_0x4626c4){const _0x245e6d=a0_0x2e14af;let _0x42569f={'Content-Type':'application/json','Accept':_0x245e6d(0x198)};if(this[_0x245e6d(0x1c6)])_0x42569f[_0x245e6d(0x1a5)]=_0x245e6d(0x185)+this[_0x245e6d(0x1c6)];let _0x413b26=await(await fetch(this['url']+_0x245e6d(0x1c4),{'method':_0x245e6d(0x1cf),'headers':_0x42569f,'body':JSON['stringify']({'jsonrpc':_0x245e6d(0x183),'id':Date['now'](),'method':_0x245e6d(0x173),'params':{'name':_0x58aab2,'arguments':_0x4626c4}})}))[_0x245e6d(0x1c9)](),_0x5a6c04=_0x413b26['match'](/data: (.+)/),_0x1765ff=_0x5a6c04?JSON[_0x245e6d(0x19f)](_0x5a6c04[0x1]):JSON['parse'](_0x413b26),_0x1787a7=_0x1765ff?.['result']?.[_0x245e6d(0x1a6)]?.[0x0]?.['text'];return _0x1787a7?JSON[_0x245e6d(0x19f)](_0x1787a7):_0x1765ff;}async['connect'](){const _0x24c8f5=a0_0x2e14af;if(this['running'])return;this[_0x24c8f5(0x19d)]=!0x0,await this[_0x24c8f5(0x179)](_0x24c8f5(0x164)),this[_0x24c8f5(0x1de)](_0x24c8f5(0x1c7)),this[_0x24c8f5(0x18e)]=setInterval(()=>{const _0x28ff9c=_0x24c8f5;this[_0x28ff9c(0x179)]('idle')[_0x28ff9c(0x1d0)](_0x46e34d=>this[_0x28ff9c(0x1de)](_0x28ff9c(0x1ac)+_0x46e34d['message']));},this[_0x24c8f5(0x17b)]),this[_0x24c8f5(0x1b8)]();}async[a0_0x2e14af(0x16b)](){const _0x3ff7e2=a0_0x2e14af;if(this['running']=!0x1,this[_0x3ff7e2(0x1d3)]?.[_0x3ff7e2(0x1cb)](),this[_0x3ff7e2(0x18e)])clearInterval(this[_0x3ff7e2(0x18e)]);await this[_0x3ff7e2(0x179)](_0x3ff7e2(0x168))[_0x3ff7e2(0x1d0)](()=>{}),this[_0x3ff7e2(0x1de)]('disconnected');}async['send'](_0x383f52,_0x5361c4,_0x49d6e4=a0_0x2e14af(0x197)){const _0x250352=a0_0x2e14af;return Y({'alias':_0x383f52,'fromAlias':this['alias']},{'log':_0x4e2de8=>console[_0x250352(0x1de)](_0x4e2de8),'send':()=>this[_0x250352(0x19c)](_0x250352(0x19a),{'alias':_0x383f52,'task':_0x5361c4,'priority':_0x49d6e4,'from_session':this[_0x250352(0x1bc)]})});}async[a0_0x2e14af(0x1c8)](_0x37eee8,_0x2d42e5){const _0x1c1a26=a0_0x2e14af;return this[_0x1c1a26(0x19c)](_0x1c1a26(0x1d2),{'alias':_0x37eee8,'message':_0x2d42e5,'from_session':this[_0x1c1a26(0x1bc)]});}async[a0_0x2e14af(0x1bd)](_0x128925,_0x39a10e,_0xaa947c='completed'){const _0x13b78a=a0_0x2e14af;return this[_0x13b78a(0x19c)]('send_reply',{'in_reply_to':_0x128925,'text':_0x39a10e,'status':_0xaa947c});}async[a0_0x2e14af(0x179)](_0x3d3ee1,_0x561b48){const _0x347301=a0_0x2e14af;return this[_0x347301(0x19c)]('report_status',{'resume_id':this[_0x347301(0x1ce)],'alias':this[_0x347301(0x1bc)],'status':_0x3d3ee1,'server':a0_0xe61605(),'hostname':a0_0xe61605(),'agent':this[_0x347301(0x1d1)],'project_dir':process[_0x347301(0x18a)](),..._0x561b48});}async[a0_0x2e14af(0x166)](){const _0x45f17d=a0_0x2e14af;return this[_0x45f17d(0x19c)](_0x45f17d(0x1bf),{});}async[a0_0x2e14af(0x174)](_0x224a74,_0x253edf){const _0x35fd99=a0_0x2e14af;return this['call']('broadcast',{'message':_0x224a74,'filter_server':_0x253edf?.[_0x35fd99(0x193)],'filter_status':_0x253edf?.[_0x35fd99(0x179)]});}async[a0_0x2e14af(0x1b8)](){const _0x3f40a=a0_0x2e14af;let _0x4d5338=encodeURIComponent(this[_0x3f40a(0x1bc)]),_0x3f751c=this['url']+_0x3f40a(0x170)+_0x4d5338,_0x5c9406=this['reconnectDelay'];while(this[_0x3f40a(0x19d)]){try{this[_0x3f40a(0x1d3)]=new AbortController();let _0x32fecc={'Accept':'text/event-stream'};if(this[_0x3f40a(0x1c6)])_0x32fecc[_0x3f40a(0x1a5)]=_0x3f40a(0x185)+this['token'];let _0x36f5c8=await fetch(_0x3f751c,{'headers':_0x32fecc,'signal':this[_0x3f40a(0x1d3)][_0x3f40a(0x184)]});if(!_0x36f5c8['ok']||!_0x36f5c8[_0x3f40a(0x1d5)]){this['log'](_0x3f40a(0x1da)+_0x36f5c8[_0x3f40a(0x179)]),await this['sleep'](_0x5c9406),_0x5c9406=Math[_0x3f40a(0x187)](_0x5c9406*1.5,0xea60);continue;}_0x5c9406=this[_0x3f40a(0x178)];let _0x1982c5=_0x36f5c8['body'][_0x3f40a(0x1af)](),_0x561dc9=new TextDecoder(),_0x805bb7='';while(this['running']){let {done:_0x52937f,value:_0x585059}=await _0x1982c5[_0x3f40a(0x1c3)]();if(_0x52937f)break;_0x805bb7+=_0x561dc9['decode'](_0x585059,{'stream':!0x0});let _0x5b193f=_0x805bb7['split']('\x0a');_0x805bb7=_0x5b193f[_0x3f40a(0x1ab)]()||'';for(let _0x5097ee of _0x5b193f){if(!_0x5097ee['startsWith']('data:\x20'))continue;try{let _0xd09995=JSON[_0x3f40a(0x19f)](_0x5097ee[_0x3f40a(0x1b6)](0x6));if(_0xd09995[_0x3f40a(0x172)]==='connected'){this['log'](_0x3f40a(0x1c5)),this[_0x3f40a(0x1a1)](_0x3f40a(0x1a7));continue;}if(_0xd09995[_0x3f40a(0x172)]===_0x3f40a(0x1aa)||_0xd09995[_0x3f40a(0x172)]===_0x3f40a(0x188)||_0xd09995[_0x3f40a(0x172)]==='broadcast')await this['processInbox']();}catch{}}}}catch(_0x489e1d){if(_0x489e1d[_0x3f40a(0x16c)]===_0x3f40a(0x17e))break;this[_0x3f40a(0x1a1)](_0x3f40a(0x17a),_0x489e1d),this[_0x3f40a(0x1de)](_0x3f40a(0x1d4)+_0x489e1d[_0x3f40a(0x1c8)]);}if(this[_0x3f40a(0x19d)])this[_0x3f40a(0x1a1)](_0x3f40a(0x192)),this[_0x3f40a(0x1de)](_0x3f40a(0x171)+_0x5c9406/0x3e8+_0x3f40a(0x1dd)),await this[_0x3f40a(0x18c)](_0x5c9406),_0x5c9406=Math['min'](_0x5c9406*1.5,0xea60);}}async['processInbox'](){const _0x5488ba=a0_0x2e14af;try{let _0x584494=(await this[_0x5488ba(0x19c)](_0x5488ba(0x195),{'alias':this[_0x5488ba(0x1bc)],'limit':0xa}))?.[_0x5488ba(0x167)]||[];for(let _0x58ef15 of _0x584494)await this[_0x5488ba(0x19c)]('ack_inbox',{'alias':this[_0x5488ba(0x1bc)],'message_id':_0x58ef15['id']}),this[_0x5488ba(0x1de)]('←\x20'+_0x58ef15['from_session']+':\x20'+_0x58ef15[_0x5488ba(0x1a6)][_0x5488ba(0x1b6)](0x0,0x3c)),this[_0x5488ba(0x1a1)](_0x5488ba(0x169),_0x58ef15),this[_0x5488ba(0x1a1)](_0x5488ba(0x1c8),_0x58ef15);}catch(_0x1d42ef){this['log'](_0x5488ba(0x1a2)+_0x1d42ef[_0x5488ba(0x1c8)]);}}[a0_0x2e14af(0x18c)](_0x3ed724){return new Promise(_0x26418c=>setTimeout(_0x26418c,_0x3ed724));}}var F=$;function a0_0x588d(){const _0x2aec35=['20086kcWnkp','lifecycleTracking','new_task','pop','heartbeat\x20failed:\x20','5864IwDrmd','sdk-','getReader','toAlias','<unknown>','CommHub\x20response\x20omitted\x20task_id','\x20parent_task_id=','CommHub\x20rejected\x20task','task.send.delivered','slice','1413FwcRrI','connectSSE','now','mcp_http','\x20error=','alias','reply','8392958ZUKLVf','get_all_status','task.replied','error_code','parent_task_id','read','/mcp','SSE\x20connected','token','registered','message','text','63hWmILC','abort','to_alias','fromAlias','resumeId','POST','catch','agent','send_message','sseAbort','SSE\x20error:\x20','body','6422340dBqgco','networkId','sdk','13wKFYsn','SSE\x20failed:\x20','\x20to=','8llTIRn','s...','log','1800960QJqquc','network_id','\x20duration_ms=','string','send','idle','send_rejected','getAllStatus','messages','offline','task','3624lRRXSy','disconnect','name','toTimeString','task_id','task.send.start','/events/','SSE\x20reconnecting\x20in\x20','type','tools/call','broadcast','autoConnect','replace','duration_ms','reconnectDelay','status','error','heartbeatInterval','27764XZAvhc','send_failed','AbortError','transport','toString','json','\x20from=','2.0','signal','Bearer\x20','task.started','min','new_message','failed','cwd','message_id','sleep','9164582ANPIjq','heartbeatTimer','task.expired','\x20lifecycle=','task.send.failed','disconnected','server','delivered','get_inbox','5SZooqk','normal','application/json,\x20text/event-stream','url','send_task','<pending>','call','running','parentTaskId','parse','not_tracked','emit','inbox\x20error:\x20','\x20task_id=','14MEblnH','Authorization','content','connected'];a0_0x588d=function(){return _0x2aec35;};return a0_0x588d();}export{F as default,$ as CommHub};
|