@sleep2agi/agent-network 2.3.0-preview.64 → 2.3.0-preview.65

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
- function a0_0x3bfa(){const _0x3d7358=['task.ack','heartbeatInterval','fromAlias','running','toTimeString','\x20duration_ms=','idle','disconnected','send','266lCIFue','replace','emit','tools/call','not_tracked','name','5txyxqQ','task.send.failed','offline','\x20network_id=','[REDACTED]','reply','heartbeat\x20failed:\x20','json','send_message','\x20from=','task.expired','CommHub\x20response\x20omitted\x20task_id','2.0','send_reply','AbortError','557418hnXXiJ','1633373gYTycX','/mcp','now','parent_task_id','lifecycleTracking','parse','error','sending','cwd','catch','24524631EPzGiT','getAllStatus','agent','get_inbox','heartbeatTimer','sseAbort','slice','/events/','string','broadcast','new_message','url','status','failed','networkId','sdk-','to_alias','2633648kvHJHC','getReader','send_task',']\x20[commhub:','\x20task_id=','token','11789jAQGXC','message','alias','call','reconnectDelay','send_failed','type','\x20parent_task_id=','ack_inbox','task.replied','abort','resumeId','messages','new_task','141474MIogpN','from_alias','\x20lifecycle=','duration_ms','delivered','pop','Authorization','toString','SSE\x20error:\x20','server','body','Bearer\x20','SSE\x20connected','transport','from_session','autoConnect','error_code','get_all_status','text','content','614824FVaMxW','<unknown>','<pending>','message_id','log','connectSSE','completed','disconnect','task.send.start','task.started','task','[commhub:task]\x20','\x20error=','read','connected','<missing>','connect','sleep','stringify','SSE\x20failed:\x20','task_id','POST','normal','parentTaskId','processInbox','error_message','min','split'];a0_0x3bfa=function(){return _0x3d7358;};return a0_0x3bfa();}const a0_0x12a50f=a0_0x20c2;(function(_0x2c8deb,_0x9fa7d0){const _0x1406a7=a0_0x20c2,_0x3969a9=_0x2c8deb();while(!![]){try{const _0x1c1308=-parseInt(_0x1406a7(0x124))/0x1*(parseInt(_0x1406a7(0x16b))/0x2)+parseInt(_0x1406a7(0x132))/0x3+parseInt(_0x1406a7(0x146))/0x4+-parseInt(_0x1406a7(0x171))/0x5*(-parseInt(_0x1406a7(0x180))/0x6)+-parseInt(_0x1406a7(0x181))/0x7+-parseInt(_0x1406a7(0x19c))/0x8+parseInt(_0x1406a7(0x18b))/0x9;if(_0x1c1308===_0x9fa7d0)break;else _0x3969a9['push'](_0x3969a9['shift']());}catch(_0x1731a4){_0x3969a9['push'](_0x3969a9['shift']());}}}(a0_0x3bfa,0xd8db4));import{EventEmitter as a0_0x5cf0ad}from'events';import{hostname as a0_0x23411e}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xa0cdfe,_0x5951bd)=>(_0xa0cdfe??_0x5951bd)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0xceab9){const _0x526f1d=a0_0x20c2;return(_0xceab9 instanceof Error?_0xceab9['message']:String(_0xceab9??'unknown\x20error'))['replace'](K,_0x526f1d(0x175))[_0x526f1d(0x16c)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x56f2d8,_0x84929a=process.env.ANET_TASK_TRACE_FORMAT===a0_0x12a50f(0x178)){const _0x377926=a0_0x12a50f;if(_0x84929a)return JSON[_0x377926(0x158)](_0x56f2d8);let _0x9879f0=L(_0x56f2d8[_0x377926(0x184)],_0x377926(0x155)),_0x46b888=L(_0x56f2d8[_0x377926(0x15a)],_0x377926(0x148)),_0x3816b7=_0x56f2d8[_0x377926(0x142)]?_0x377926(0x152)+_0x56f2d8['error_code']+':'+(_0x56f2d8[_0x377926(0x15f)]??''):'';return _0x377926(0x151)+_0x56f2d8[_0x377926(0x197)]+_0x377926(0x17a)+L(_0x56f2d8[_0x377926(0x133)],_0x377926(0x147))+'\x20to='+L(_0x56f2d8[_0x377926(0x19b)],'<unknown>')+_0x377926(0x122)+_0x46b888+_0x377926(0x12b)+_0x9879f0+_0x377926(0x174)+L(_0x56f2d8['network_id'],_0x377926(0x147))+'\x20transport='+_0x56f2d8[_0x377926(0x13f)]+_0x377926(0x167)+_0x56f2d8[_0x377926(0x135)]+_0x377926(0x134)+_0x56f2d8['lifecycle_tracking']+_0x3816b7;}function U(_0x40c184){const _0x1f46fc=a0_0x12a50f;return{'event':{'sending':_0x1f46fc(0x14e),'delivered':'task.send.delivered','failed':_0x1f46fc(0x172),'acked':_0x1f46fc(0x162),'started':_0x1f46fc(0x14f),'replied':_0x1f46fc(0x12d),'expired':_0x1f46fc(0x17b)}[_0x40c184[_0x1f46fc(0x197)]],..._0x40c184};}function a0_0x20c2(_0x3c7db9,_0x44cd34){_0x3c7db9=_0x3c7db9-0x121;const _0x3bfa2e=a0_0x3bfa();let _0x20c230=_0x3bfa2e[_0x3c7db9];return _0x20c230;}function j(_0x3a8eea){const _0x3627d8=a0_0x12a50f;let _0x49932f=_0x3a8eea?.[_0x3627d8(0x15a)]||_0x3a8eea?.['message_id']||_0x3a8eea?.['id'];if(_0x49932f)return String(_0x49932f);let _0x46fde2=_0x3a8eea?.[_0x3627d8(0x145)]?.[0x0]?.[_0x3627d8(0x144)];if(typeof _0x46fde2!==_0x3627d8(0x193))return null;try{let _0x5c7a94=JSON[_0x3627d8(0x186)](_0x46fde2);return _0x5c7a94?.[_0x3627d8(0x15a)]||_0x5c7a94?.[_0x3627d8(0x149)]||_0x5c7a94?.['id']||null;}catch{return null;}}async function X(_0x1bbeeb,_0x28010b){const _0x2b236c=a0_0x12a50f;let _0x564304=_0x28010b[_0x2b236c(0x183)]??Date['now'],_0x1c067d=_0x564304(),_0x23eca7=(_0x3e80b5,_0x1d4152,_0x4a152,_0x24db1d)=>{const _0x5bffc1=_0x2b236c;_0x28010b[_0x5bffc1(0x14a)](O(U({'from_alias':_0x1bbeeb[_0x5bffc1(0x164)],'to_alias':_0x1bbeeb['toAlias'],'task_id':_0x1d4152,'parent_task_id':_0x1bbeeb[_0x5bffc1(0x15d)],'network_id':_0x1bbeeb[_0x5bffc1(0x199)],'transport':_0x1bbeeb[_0x5bffc1(0x13f)],'status':_0x3e80b5,'duration_ms':_0x564304()-_0x1c067d,'lifecycle_tracking':_0x1bbeeb[_0x5bffc1(0x185)],..._0x4a152!==void 0x0?{'error_code':_0x24db1d||_0x5bffc1(0x129),'error_message':N(_0x4a152)}:{}})));};_0x23eca7(_0x2b236c(0x188),null);try{let _0x4b0b16=await _0x28010b[_0x2b236c(0x16a)](),_0x38485a=j(_0x4b0b16);if(_0x38485a)_0x23eca7(_0x2b236c(0x136),_0x38485a);else{if(_0x4b0b16?.['ok']===!0x1||_0x4b0b16?.[_0x2b236c(0x187)])_0x23eca7(_0x2b236c(0x198),_0x38485a,_0x4b0b16?.['error']||'CommHub\x20rejected\x20task','send_rejected');else _0x23eca7(_0x2b236c(0x198),null,_0x2b236c(0x17c),'missing_task_id');}return _0x4b0b16;}catch(_0x1ee81a){throw _0x23eca7(_0x2b236c(0x198),null,_0x1ee81a,_0x2b236c(0x129)),_0x1ee81a;}}async function Y(_0x5b5ca3,_0x5b15ed){const _0xfaf945=a0_0x12a50f;return X({'fromAlias':_0x5b5ca3[_0xfaf945(0x164)],'toAlias':_0x5b5ca3['alias'],'parentTaskId':_0x5b5ca3[_0xfaf945(0x15d)]||null,'networkId':_0x5b5ca3['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0xfaf945(0x16f)},_0x5b15ed);}class $ extends a0_0x5cf0ad{[a0_0x12a50f(0x196)];[a0_0x12a50f(0x126)];[a0_0x12a50f(0x123)];[a0_0x12a50f(0x18d)];['resumeId'];[a0_0x12a50f(0x163)];[a0_0x12a50f(0x128)];['heartbeatTimer'];['sseAbort'];[a0_0x12a50f(0x165)]=!0x1;constructor(_0x121f76){const _0x587a18=a0_0x12a50f;super();if(this['url']=_0x121f76[_0x587a18(0x196)][_0x587a18(0x16c)](/\/$/,''),this[_0x587a18(0x126)]=_0x121f76[_0x587a18(0x126)],this[_0x587a18(0x123)]=_0x121f76[_0x587a18(0x123)],this['agent']=_0x121f76[_0x587a18(0x18d)]||'sdk',this['resumeId']=_0x587a18(0x19a)+_0x121f76[_0x587a18(0x126)]+'-'+Date[_0x587a18(0x183)]()[_0x587a18(0x139)](0x24),this[_0x587a18(0x163)]=_0x121f76[_0x587a18(0x163)]??0x2bf20,this[_0x587a18(0x128)]=_0x121f76[_0x587a18(0x128)]??0xbb8,_0x121f76[_0x587a18(0x141)]!==!0x1)this[_0x587a18(0x156)]();}[a0_0x12a50f(0x14a)](_0x11b031){const _0x339f1c=a0_0x12a50f;console['log']('['+new Date()[_0x339f1c(0x166)]()[_0x339f1c(0x191)](0x0,0x8)+_0x339f1c(0x121)+this[_0x339f1c(0x126)]+']\x20'+_0x11b031);}async[a0_0x12a50f(0x127)](_0x4da697,_0x1c8396){const _0x4e6ca1=a0_0x12a50f;let _0x2da970={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x2da970[_0x4e6ca1(0x138)]=_0x4e6ca1(0x13d)+this[_0x4e6ca1(0x123)];let _0x5dbff1=await(await fetch(this[_0x4e6ca1(0x196)]+_0x4e6ca1(0x182),{'method':_0x4e6ca1(0x15b),'headers':_0x2da970,'body':JSON[_0x4e6ca1(0x158)]({'jsonrpc':_0x4e6ca1(0x17d),'id':Date['now'](),'method':_0x4e6ca1(0x16e),'params':{'name':_0x4da697,'arguments':_0x1c8396}})}))[_0x4e6ca1(0x144)](),_0x110af6=_0x5dbff1['match'](/data: (.+)/),_0xf76ee8=_0x110af6?JSON['parse'](_0x110af6[0x1]):JSON[_0x4e6ca1(0x186)](_0x5dbff1),_0x33cde9=_0xf76ee8?.['result']?.[_0x4e6ca1(0x145)]?.[0x0]?.[_0x4e6ca1(0x144)];return _0x33cde9?JSON['parse'](_0x33cde9):_0xf76ee8;}async[a0_0x12a50f(0x156)](){const _0x26baea=a0_0x12a50f;if(this[_0x26baea(0x165)])return;this[_0x26baea(0x165)]=!0x0,await this[_0x26baea(0x197)](_0x26baea(0x168)),this[_0x26baea(0x14a)]('registered'),this[_0x26baea(0x18f)]=setInterval(()=>{const _0x273de0=_0x26baea;this[_0x273de0(0x197)](_0x273de0(0x168))[_0x273de0(0x18a)](_0x37fe76=>this[_0x273de0(0x14a)](_0x273de0(0x177)+_0x37fe76[_0x273de0(0x125)]));},this[_0x26baea(0x163)]),this[_0x26baea(0x14b)]();}async[a0_0x12a50f(0x14d)](){const _0x5153d4=a0_0x12a50f;if(this[_0x5153d4(0x165)]=!0x1,this[_0x5153d4(0x190)]?.[_0x5153d4(0x12e)](),this[_0x5153d4(0x18f)])clearInterval(this[_0x5153d4(0x18f)]);await this[_0x5153d4(0x197)](_0x5153d4(0x173))[_0x5153d4(0x18a)](()=>{}),this[_0x5153d4(0x14a)](_0x5153d4(0x169));}async['send'](_0x2b3003,_0x2dcf7b,_0xf9fe3b=a0_0x12a50f(0x15c)){const _0x3e4c59=a0_0x12a50f;return Y({'alias':_0x2b3003,'fromAlias':this[_0x3e4c59(0x126)]},{'log':_0xdd0cf6=>console[_0x3e4c59(0x14a)](_0xdd0cf6),'send':()=>this[_0x3e4c59(0x127)](_0x3e4c59(0x19e),{'alias':_0x2b3003,'task':_0x2dcf7b,'priority':_0xf9fe3b,'from_session':this[_0x3e4c59(0x126)]})});}async[a0_0x12a50f(0x125)](_0xbe2a00,_0x46cb1f){const _0x25c3af=a0_0x12a50f;return this[_0x25c3af(0x127)](_0x25c3af(0x179),{'alias':_0xbe2a00,'message':_0x46cb1f,'from_session':this[_0x25c3af(0x126)]});}async[a0_0x12a50f(0x176)](_0x149882,_0x46becb,_0x23ae9f=a0_0x12a50f(0x14c)){const _0x396aac=a0_0x12a50f;return this[_0x396aac(0x127)](_0x396aac(0x17e),{'in_reply_to':_0x149882,'text':_0x46becb,'status':_0x23ae9f});}async[a0_0x12a50f(0x197)](_0x3fcd77,_0x37be61){const _0x509cab=a0_0x12a50f;return this[_0x509cab(0x127)]('report_status',{'resume_id':this[_0x509cab(0x12f)],'alias':this[_0x509cab(0x126)],'status':_0x3fcd77,'server':a0_0x23411e(),'hostname':a0_0x23411e(),'agent':this[_0x509cab(0x18d)],'project_dir':process[_0x509cab(0x189)](),..._0x37be61});}async[a0_0x12a50f(0x18c)](){const _0x22d5c3=a0_0x12a50f;return this[_0x22d5c3(0x127)](_0x22d5c3(0x143),{});}async['broadcast'](_0x5338e6,_0x55e805){const _0x205993=a0_0x12a50f;return this[_0x205993(0x127)](_0x205993(0x194),{'message':_0x5338e6,'filter_server':_0x55e805?.[_0x205993(0x13b)],'filter_status':_0x55e805?.[_0x205993(0x197)]});}async[a0_0x12a50f(0x14b)](){const _0x5b5205=a0_0x12a50f;let _0x4ae594=encodeURIComponent(this[_0x5b5205(0x126)]),_0x49b19b=this[_0x5b5205(0x196)]+_0x5b5205(0x192)+_0x4ae594,_0x481067=this[_0x5b5205(0x128)];while(this[_0x5b5205(0x165)]){try{this['sseAbort']=new AbortController();let _0x444180={'Accept':'text/event-stream'};if(this[_0x5b5205(0x123)])_0x444180[_0x5b5205(0x138)]=_0x5b5205(0x13d)+this['token'];let _0x286e02=await fetch(_0x49b19b,{'headers':_0x444180,'signal':this['sseAbort']['signal']});if(!_0x286e02['ok']||!_0x286e02[_0x5b5205(0x13c)]){this[_0x5b5205(0x14a)](_0x5b5205(0x159)+_0x286e02[_0x5b5205(0x197)]),await this[_0x5b5205(0x157)](_0x481067),_0x481067=Math[_0x5b5205(0x160)](_0x481067*1.5,0xea60);continue;}_0x481067=this[_0x5b5205(0x128)];let _0x1939b4=_0x286e02[_0x5b5205(0x13c)][_0x5b5205(0x19d)](),_0x29fd8d=new TextDecoder(),_0x41755a='';while(this[_0x5b5205(0x165)]){let {done:_0x2102c4,value:_0x3dcc88}=await _0x1939b4[_0x5b5205(0x153)]();if(_0x2102c4)break;_0x41755a+=_0x29fd8d['decode'](_0x3dcc88,{'stream':!0x0});let _0x393363=_0x41755a[_0x5b5205(0x161)]('\x0a');_0x41755a=_0x393363[_0x5b5205(0x137)]()||'';for(let _0x1d8dad of _0x393363){if(!_0x1d8dad['startsWith']('data:\x20'))continue;try{let _0x4b262d=JSON[_0x5b5205(0x186)](_0x1d8dad[_0x5b5205(0x191)](0x6));if(_0x4b262d['type']===_0x5b5205(0x154)){this[_0x5b5205(0x14a)](_0x5b5205(0x13e)),this[_0x5b5205(0x16d)](_0x5b5205(0x154));continue;}if(_0x4b262d[_0x5b5205(0x12a)]===_0x5b5205(0x131)||_0x4b262d[_0x5b5205(0x12a)]===_0x5b5205(0x195)||_0x4b262d[_0x5b5205(0x12a)]===_0x5b5205(0x194))await this[_0x5b5205(0x15e)]();}catch{}}}}catch(_0x341ac7){if(_0x341ac7[_0x5b5205(0x170)]===_0x5b5205(0x17f))break;this[_0x5b5205(0x16d)](_0x5b5205(0x187),_0x341ac7),this[_0x5b5205(0x14a)](_0x5b5205(0x13a)+_0x341ac7[_0x5b5205(0x125)]);}if(this[_0x5b5205(0x165)])this['emit'](_0x5b5205(0x169)),this[_0x5b5205(0x14a)]('SSE\x20reconnecting\x20in\x20'+_0x481067/0x3e8+'s...'),await this[_0x5b5205(0x157)](_0x481067),_0x481067=Math[_0x5b5205(0x160)](_0x481067*1.5,0xea60);}}async[a0_0x12a50f(0x15e)](){const _0x22389e=a0_0x12a50f;try{let _0x4741ef=(await this[_0x22389e(0x127)](_0x22389e(0x18e),{'alias':this[_0x22389e(0x126)],'limit':0xa}))?.[_0x22389e(0x130)]||[];for(let _0x58e9db of _0x4741ef)await this[_0x22389e(0x127)](_0x22389e(0x12c),{'alias':this['alias'],'message_id':_0x58e9db['id']}),this[_0x22389e(0x14a)]('←\x20'+_0x58e9db[_0x22389e(0x140)]+':\x20'+_0x58e9db[_0x22389e(0x145)][_0x22389e(0x191)](0x0,0x3c)),this[_0x22389e(0x16d)](_0x22389e(0x150),_0x58e9db),this[_0x22389e(0x16d)](_0x22389e(0x125),_0x58e9db);}catch(_0x266791){this[_0x22389e(0x14a)]('inbox\x20error:\x20'+_0x266791[_0x22389e(0x125)]);}}[a0_0x12a50f(0x157)](_0x1e98b3){return new Promise(_0x4a2652=>setTimeout(_0x4a2652,_0x1e98b3));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x1a7b7b=a0_0xb7d1;(function(_0x57df4e,_0x3cfdd6){const _0x3e2d41=a0_0xb7d1,_0x413f5e=_0x57df4e();while(!![]){try{const _0x229d94=-parseInt(_0x3e2d41(0x1be))/0x1+parseInt(_0x3e2d41(0x18e))/0x2+-parseInt(_0x3e2d41(0x1d8))/0x3*(-parseInt(_0x3e2d41(0x189))/0x4)+parseInt(_0x3e2d41(0x1a9))/0x5*(parseInt(_0x3e2d41(0x164))/0x6)+-parseInt(_0x3e2d41(0x181))/0x7+parseInt(_0x3e2d41(0x19e))/0x8*(parseInt(_0x3e2d41(0x1d9))/0x9)+-parseInt(_0x3e2d41(0x1b0))/0xa*(parseInt(_0x3e2d41(0x17a))/0xb);if(_0x229d94===_0x3cfdd6)break;else _0x413f5e['push'](_0x413f5e['shift']());}catch(_0x316152){_0x413f5e['push'](_0x413f5e['shift']());}}}(a0_0x27fe,0x4d3b2));import{EventEmitter as a0_0x3ef3ff}from'events';import{hostname as a0_0x4f787a}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x21fd9e,_0x49dcb5)=>(_0x21fd9e??_0x49dcb5)[a0_0x1a7b7b(0x1ca)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x1a7b7b(0x1aa)](0x0,0xf0);function a0_0xb7d1(_0x105827,_0x236745){_0x105827=_0x105827-0x159;const _0x27fe75=a0_0x27fe();let _0xb7d1c8=_0x27fe75[_0x105827];return _0xb7d1c8;}function N(_0x2d7611){const _0x2eb664=a0_0x1a7b7b;return(_0x2d7611 instanceof Error?_0x2d7611['message']:String(_0x2d7611??_0x2eb664(0x19f)))[_0x2eb664(0x1ca)](K,_0x2eb664(0x1b8))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x4a4817,_0x4316fb=process.env.ANET_TASK_TRACE_FORMAT===a0_0x1a7b7b(0x15d)){const _0x366580=a0_0x1a7b7b;if(_0x4316fb)return JSON[_0x366580(0x1a2)](_0x4a4817);let _0x186079=L(_0x4a4817[_0x366580(0x197)],'<missing>'),_0x179d0a=L(_0x4a4817[_0x366580(0x1a3)],_0x366580(0x1ab)),_0x545b25=_0x4a4817[_0x366580(0x166)]?_0x366580(0x196)+_0x4a4817['error_code']+':'+(_0x4a4817[_0x366580(0x198)]??''):'';return _0x366580(0x1ac)+_0x4a4817[_0x366580(0x177)]+_0x366580(0x1ba)+L(_0x4a4817['from_alias'],_0x366580(0x1a1))+_0x366580(0x19a)+L(_0x4a4817[_0x366580(0x199)],_0x366580(0x1a1))+_0x366580(0x1c7)+_0x179d0a+'\x20parent_task_id='+_0x186079+_0x366580(0x1a6)+L(_0x4a4817[_0x366580(0x1cf)],_0x366580(0x1a1))+_0x366580(0x167)+_0x4a4817[_0x366580(0x1b3)]+_0x366580(0x1d6)+_0x4a4817[_0x366580(0x1b7)]+_0x366580(0x1da)+_0x4a4817[_0x366580(0x159)]+_0x545b25;}function U(_0x46151d){const _0x5c6e74=a0_0x1a7b7b;return{'event':{'sending':_0x5c6e74(0x1b4),'delivered':'task.send.delivered','failed':'task.send.failed','acked':'task.ack','started':'task.started','replied':_0x5c6e74(0x1c2),'expired':_0x5c6e74(0x161)}[_0x46151d[_0x5c6e74(0x177)]],..._0x46151d};}function j(_0x38bd1b){const _0x2130af=a0_0x1a7b7b;let _0x22edb4=_0x38bd1b?.['task_id']||_0x38bd1b?.[_0x2130af(0x16d)]||_0x38bd1b?.['id'];if(_0x22edb4)return String(_0x22edb4);let _0x4391f9=_0x38bd1b?.['content']?.[0x0]?.[_0x2130af(0x182)];if(typeof _0x4391f9!==_0x2130af(0x162))return null;try{let _0x55f7d7=JSON[_0x2130af(0x1bd)](_0x4391f9);return _0x55f7d7?.[_0x2130af(0x1a3)]||_0x55f7d7?.[_0x2130af(0x16d)]||_0x55f7d7?.['id']||null;}catch{return null;}}async function X(_0x25ea99,_0x5a2c5c){const _0x10f98b=a0_0x1a7b7b;let _0x415d12=_0x5a2c5c['now']??Date[_0x10f98b(0x176)],_0x4f1a0f=_0x415d12(),_0x480ab7=(_0x2768f0,_0x180c0c,_0x291e3f,_0x1ab843)=>{const _0x43aded=_0x10f98b;_0x5a2c5c['log'](O(U({'from_alias':_0x25ea99[_0x43aded(0x1db)],'to_alias':_0x25ea99[_0x43aded(0x1d2)],'task_id':_0x180c0c,'parent_task_id':_0x25ea99[_0x43aded(0x1d1)],'network_id':_0x25ea99['networkId'],'transport':_0x25ea99['transport'],'status':_0x2768f0,'duration_ms':_0x415d12()-_0x4f1a0f,'lifecycle_tracking':_0x25ea99[_0x43aded(0x15b)],..._0x291e3f!==void 0x0?{'error_code':_0x1ab843||_0x43aded(0x18a),'error_message':N(_0x291e3f)}:{}})));};_0x480ab7('sending',null);try{let _0x2d3c76=await _0x5a2c5c[_0x10f98b(0x19d)](),_0x49aeae=j(_0x2d3c76);if(_0x49aeae)_0x480ab7(_0x10f98b(0x1b9),_0x49aeae);else{if(_0x2d3c76?.['ok']===!0x1||_0x2d3c76?.[_0x10f98b(0x15f)])_0x480ab7('failed',_0x49aeae,_0x2d3c76?.[_0x10f98b(0x15f)]||_0x10f98b(0x1cc),_0x10f98b(0x183));else _0x480ab7('failed',null,_0x10f98b(0x191),'missing_task_id');}return _0x2d3c76;}catch(_0x5ae34c){throw _0x480ab7(_0x10f98b(0x18c),null,_0x5ae34c,'send_failed'),_0x5ae34c;}}function a0_0x27fe(){const _0x3dc577=['decode','emit','registered','name','76xYNayB','send_failed','alias','failed','cwd','603646migLvK','networkId','report_status','CommHub\x20response\x20omitted\x20task_id','agent','messages','disconnected','s...','\x20error=','parent_task_id','error_message','to_alias','\x20to=','connectSSE','get_all_status','send','8DTWIpp','unknown\x20error','sseAbort','<unknown>','stringify','task_id','tools/call','mcp_http','\x20network_id=','pop','heartbeatInterval','10bUKkgA','slice','<pending>','[commhub:task]\x20','sdk','get_inbox','split','40jtDtVV','result','idle','transport','task.send.start','heartbeatTimer','ack_inbox','duration_ms','[REDACTED]','delivered','\x20from=','heartbeat\x20failed:\x20','SSE\x20reconnecting\x20in\x20','parse','122831QAIlit','task','POST','new_task','task.replied','log','message','Authorization','abort','\x20task_id=','normal','match','replace','application/json,\x20text/event-stream','CommHub\x20rejected\x20task','token','disconnect','network_id','send_task','parentTaskId','toAlias','url','from_session','2.0','\x20duration_ms=','min','12183yLeDvp','5557896cEGPKb','\x20lifecycle=','fromAlias','lifecycle_tracking','Bearer\x20','lifecycleTracking','catch','json','SSE\x20connected','error','call','task.expired','string','startsWith','155436FoJBVX','getAllStatus','error_code','\x20transport=','broadcast','application/json','reconnectDelay','toString','not_tracked','message_id','resumeId','send_reply',']\x20[commhub:','connect','sdk-','running','sleep','toTimeString','now','status','completed','/events/','43714tBnBkG','body','getReader','autoConnect','content','SSE\x20failed:\x20','type','4152911YKylCH','text','send_rejected','AbortError'];a0_0x27fe=function(){return _0x3dc577;};return a0_0x27fe();}async function Y(_0x3f4d86,_0x2a188c){const _0x5bb92f=a0_0x1a7b7b;return X({'fromAlias':_0x3f4d86['fromAlias'],'toAlias':_0x3f4d86[_0x5bb92f(0x18b)],'parentTaskId':_0x3f4d86[_0x5bb92f(0x1d1)]||null,'networkId':_0x3f4d86[_0x5bb92f(0x18f)]||null,'transport':_0x5bb92f(0x1a5),'lifecycleTracking':_0x5bb92f(0x16c)},_0x2a188c);}class $ extends a0_0x3ef3ff{[a0_0x1a7b7b(0x1d3)];['alias'];[a0_0x1a7b7b(0x1cd)];[a0_0x1a7b7b(0x192)];[a0_0x1a7b7b(0x16e)];[a0_0x1a7b7b(0x1a8)];[a0_0x1a7b7b(0x16a)];['heartbeatTimer'];[a0_0x1a7b7b(0x1a0)];[a0_0x1a7b7b(0x173)]=!0x1;constructor(_0x10d30c){const _0x15d9b0=a0_0x1a7b7b;super();if(this[_0x15d9b0(0x1d3)]=_0x10d30c[_0x15d9b0(0x1d3)]['replace'](/\/$/,''),this[_0x15d9b0(0x18b)]=_0x10d30c[_0x15d9b0(0x18b)],this['token']=_0x10d30c[_0x15d9b0(0x1cd)],this[_0x15d9b0(0x192)]=_0x10d30c['agent']||_0x15d9b0(0x1ad),this['resumeId']=_0x15d9b0(0x172)+_0x10d30c[_0x15d9b0(0x18b)]+'-'+Date[_0x15d9b0(0x176)]()[_0x15d9b0(0x16b)](0x24),this[_0x15d9b0(0x1a8)]=_0x10d30c[_0x15d9b0(0x1a8)]??0x2bf20,this[_0x15d9b0(0x16a)]=_0x10d30c['reconnectDelay']??0xbb8,_0x10d30c[_0x15d9b0(0x17d)]!==!0x1)this[_0x15d9b0(0x171)]();}[a0_0x1a7b7b(0x1c3)](_0x3af729){const _0x1922a8=a0_0x1a7b7b;console[_0x1922a8(0x1c3)]('['+new Date()[_0x1922a8(0x175)]()['slice'](0x0,0x8)+_0x1922a8(0x170)+this[_0x1922a8(0x18b)]+']\x20'+_0x3af729);}async[a0_0x1a7b7b(0x160)](_0xe4c7b6,_0x2f2390){const _0x1c2606=a0_0x1a7b7b;let _0x509df2={'Content-Type':_0x1c2606(0x169),'Accept':_0x1c2606(0x1cb)};if(this[_0x1c2606(0x1cd)])_0x509df2[_0x1c2606(0x1c5)]='Bearer\x20'+this[_0x1c2606(0x1cd)];let _0x36e012=await(await fetch(this[_0x1c2606(0x1d3)]+'/mcp',{'method':_0x1c2606(0x1c0),'headers':_0x509df2,'body':JSON[_0x1c2606(0x1a2)]({'jsonrpc':_0x1c2606(0x1d5),'id':Date[_0x1c2606(0x176)](),'method':_0x1c2606(0x1a4),'params':{'name':_0xe4c7b6,'arguments':_0x2f2390}})}))[_0x1c2606(0x182)](),_0xd7b9b5=_0x36e012[_0x1c2606(0x1c9)](/data: (.+)/),_0x107647=_0xd7b9b5?JSON[_0x1c2606(0x1bd)](_0xd7b9b5[0x1]):JSON[_0x1c2606(0x1bd)](_0x36e012),_0x40377d=_0x107647?.[_0x1c2606(0x1b1)]?.['content']?.[0x0]?.[_0x1c2606(0x182)];return _0x40377d?JSON['parse'](_0x40377d):_0x107647;}async[a0_0x1a7b7b(0x171)](){const _0x2f0c28=a0_0x1a7b7b;if(this[_0x2f0c28(0x173)])return;this[_0x2f0c28(0x173)]=!0x0,await this['status'](_0x2f0c28(0x1b2)),this[_0x2f0c28(0x1c3)](_0x2f0c28(0x187)),this[_0x2f0c28(0x1b5)]=setInterval(()=>{const _0x1da1d6=_0x2f0c28;this['status']('idle')[_0x1da1d6(0x15c)](_0x46fb73=>this['log'](_0x1da1d6(0x1bb)+_0x46fb73[_0x1da1d6(0x1c4)]));},this['heartbeatInterval']),this['connectSSE']();}async[a0_0x1a7b7b(0x1ce)](){const _0x6d4962=a0_0x1a7b7b;if(this[_0x6d4962(0x173)]=!0x1,this['sseAbort']?.[_0x6d4962(0x1c6)](),this[_0x6d4962(0x1b5)])clearInterval(this[_0x6d4962(0x1b5)]);await this[_0x6d4962(0x177)]('offline')[_0x6d4962(0x15c)](()=>{}),this[_0x6d4962(0x1c3)]('disconnected');}async[a0_0x1a7b7b(0x19d)](_0x1ee25b,_0x3c924e,_0x32683e=a0_0x1a7b7b(0x1c8)){const _0x4e5258=a0_0x1a7b7b;return Y({'alias':_0x1ee25b,'fromAlias':this[_0x4e5258(0x18b)]},{'log':_0x39d045=>console[_0x4e5258(0x1c3)](_0x39d045),'send':()=>this[_0x4e5258(0x160)](_0x4e5258(0x1d0),{'alias':_0x1ee25b,'task':_0x3c924e,'priority':_0x32683e,'from_session':this['alias']})});}async['message'](_0x5adef0,_0x31d674){const _0x163b69=a0_0x1a7b7b;return this[_0x163b69(0x160)]('send_message',{'alias':_0x5adef0,'message':_0x31d674,'from_session':this['alias']});}async['reply'](_0x4dbd91,_0x2c8d62,_0x31936c=a0_0x1a7b7b(0x178)){const _0x5c4457=a0_0x1a7b7b;return this[_0x5c4457(0x160)](_0x5c4457(0x16f),{'in_reply_to':_0x4dbd91,'text':_0x2c8d62,'status':_0x31936c});}async[a0_0x1a7b7b(0x177)](_0x569d04,_0x54086b){const _0x9cdf20=a0_0x1a7b7b;return this[_0x9cdf20(0x160)](_0x9cdf20(0x190),{'resume_id':this['resumeId'],'alias':this[_0x9cdf20(0x18b)],'status':_0x569d04,'server':a0_0x4f787a(),'hostname':a0_0x4f787a(),'agent':this['agent'],'project_dir':process[_0x9cdf20(0x18d)](),..._0x54086b});}async[a0_0x1a7b7b(0x165)](){const _0x3be1bb=a0_0x1a7b7b;return this[_0x3be1bb(0x160)](_0x3be1bb(0x19c),{});}async[a0_0x1a7b7b(0x168)](_0x24a929,_0x433873){const _0x49ff7b=a0_0x1a7b7b;return this[_0x49ff7b(0x160)](_0x49ff7b(0x168),{'message':_0x24a929,'filter_server':_0x433873?.['server'],'filter_status':_0x433873?.[_0x49ff7b(0x177)]});}async[a0_0x1a7b7b(0x19b)](){const _0x4404c8=a0_0x1a7b7b;let _0x2a85ff=encodeURIComponent(this[_0x4404c8(0x18b)]),_0x4e5f54=this['url']+_0x4404c8(0x179)+_0x2a85ff,_0x33a024=this['reconnectDelay'];while(this[_0x4404c8(0x173)]){try{this[_0x4404c8(0x1a0)]=new AbortController();let _0x446333={'Accept':'text/event-stream'};if(this['token'])_0x446333['Authorization']=_0x4404c8(0x15a)+this[_0x4404c8(0x1cd)];let _0x51f1a8=await fetch(_0x4e5f54,{'headers':_0x446333,'signal':this[_0x4404c8(0x1a0)]['signal']});if(!_0x51f1a8['ok']||!_0x51f1a8[_0x4404c8(0x17b)]){this[_0x4404c8(0x1c3)](_0x4404c8(0x17f)+_0x51f1a8['status']),await this[_0x4404c8(0x174)](_0x33a024),_0x33a024=Math[_0x4404c8(0x1d7)](_0x33a024*1.5,0xea60);continue;}_0x33a024=this[_0x4404c8(0x16a)];let _0x7f242a=_0x51f1a8[_0x4404c8(0x17b)][_0x4404c8(0x17c)](),_0x4c0fee=new TextDecoder(),_0x1f318a='';while(this['running']){let {done:_0x3906e9,value:_0x3e7805}=await _0x7f242a['read']();if(_0x3906e9)break;_0x1f318a+=_0x4c0fee[_0x4404c8(0x185)](_0x3e7805,{'stream':!0x0});let _0x3e7d05=_0x1f318a[_0x4404c8(0x1af)]('\x0a');_0x1f318a=_0x3e7d05[_0x4404c8(0x1a7)]()||'';for(let _0x1880fc of _0x3e7d05){if(!_0x1880fc[_0x4404c8(0x163)]('data:\x20'))continue;try{let _0x64fdc0=JSON[_0x4404c8(0x1bd)](_0x1880fc[_0x4404c8(0x1aa)](0x6));if(_0x64fdc0[_0x4404c8(0x180)]==='connected'){this[_0x4404c8(0x1c3)](_0x4404c8(0x15e)),this[_0x4404c8(0x186)]('connected');continue;}if(_0x64fdc0[_0x4404c8(0x180)]===_0x4404c8(0x1c1)||_0x64fdc0[_0x4404c8(0x180)]==='new_message'||_0x64fdc0[_0x4404c8(0x180)]===_0x4404c8(0x168))await this['processInbox']();}catch{}}}}catch(_0x3542a4){if(_0x3542a4[_0x4404c8(0x188)]===_0x4404c8(0x184))break;this[_0x4404c8(0x186)](_0x4404c8(0x15f),_0x3542a4),this[_0x4404c8(0x1c3)]('SSE\x20error:\x20'+_0x3542a4[_0x4404c8(0x1c4)]);}if(this['running'])this[_0x4404c8(0x186)](_0x4404c8(0x194)),this[_0x4404c8(0x1c3)](_0x4404c8(0x1bc)+_0x33a024/0x3e8+_0x4404c8(0x195)),await this['sleep'](_0x33a024),_0x33a024=Math['min'](_0x33a024*1.5,0xea60);}}async['processInbox'](){const _0x528eb2=a0_0x1a7b7b;try{let _0x106403=(await this[_0x528eb2(0x160)](_0x528eb2(0x1ae),{'alias':this['alias'],'limit':0xa}))?.[_0x528eb2(0x193)]||[];for(let _0xc09b99 of _0x106403)await this[_0x528eb2(0x160)](_0x528eb2(0x1b6),{'alias':this['alias'],'message_id':_0xc09b99['id']}),this[_0x528eb2(0x1c3)]('←\x20'+_0xc09b99[_0x528eb2(0x1d4)]+':\x20'+_0xc09b99[_0x528eb2(0x17e)][_0x528eb2(0x1aa)](0x0,0x3c)),this[_0x528eb2(0x186)](_0x528eb2(0x1bf),_0xc09b99),this['emit'](_0x528eb2(0x1c4),_0xc09b99);}catch(_0x2398c5){this[_0x528eb2(0x1c3)]('inbox\x20error:\x20'+_0x2398c5['message']);}}['sleep'](_0x2736d6){return new Promise(_0x4a4f96=>setTimeout(_0x4a4f96,_0x2736d6));}}var F=$;export{F as default,$ as CommHub};