@sleep2agi/agent-network 2.3.0-preview.161 → 2.3.0-preview.162

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_0x48433c=a0_0x25c5;(function(_0x46ea15,_0xf86193){const _0x3e2f9a=a0_0x25c5,_0x48b355=_0x46ea15();while(!![]){try{const _0x1e6afa=-parseInt(_0x3e2f9a(0x19c))/0x1+-parseInt(_0x3e2f9a(0x184))/0x2+-parseInt(_0x3e2f9a(0x1a0))/0x3+-parseInt(_0x3e2f9a(0x17f))/0x4*(-parseInt(_0x3e2f9a(0x1a3))/0x5)+-parseInt(_0x3e2f9a(0x196))/0x6*(-parseInt(_0x3e2f9a(0x1b2))/0x7)+-parseInt(_0x3e2f9a(0x1dc))/0x8*(-parseInt(_0x3e2f9a(0x199))/0x9)+-parseInt(_0x3e2f9a(0x1f2))/0xa*(-parseInt(_0x3e2f9a(0x1b1))/0xb);if(_0x1e6afa===_0xf86193)break;else _0x48b355['push'](_0x48b355['shift']());}catch(_0x283aa6){_0x48b355['push'](_0x48b355['shift']());}}}(a0_0xbe4d,0x3f44f));import{EventEmitter as a0_0x380af2}from'events';import{hostname as a0_0x106efe}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x1f4861,_0x55d04d)=>(_0x1f4861??_0x55d04d)[a0_0x48433c(0x1eb)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x48433c(0x1db)](0x0,0xf0);function N(_0x4d9f15){const _0x3edcc6=a0_0x48433c;return(_0x4d9f15 instanceof Error?_0x4d9f15[_0x3edcc6(0x1da)]:String(_0x4d9f15??'unknown\x20error'))[_0x3edcc6(0x1eb)](K,_0x3edcc6(0x18b))[_0x3edcc6(0x1eb)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x3edcc6(0x1db)](0x0,0xf0);}function O(_0x5112e6,_0x4ebefc=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x2cecd0=a0_0x48433c;if(_0x4ebefc)return JSON[_0x2cecd0(0x19f)](_0x5112e6);let _0x1e83df=L(_0x5112e6['parent_task_id'],'<missing>'),_0x1e1b52=L(_0x5112e6['task_id'],_0x2cecd0(0x1ac)),_0x1b33ca=_0x5112e6[_0x2cecd0(0x1e1)]?'\x20error='+_0x5112e6[_0x2cecd0(0x1e1)]+':'+(_0x5112e6['error_message']??''):'';return _0x2cecd0(0x1be)+_0x5112e6[_0x2cecd0(0x19a)]+_0x2cecd0(0x1ae)+L(_0x5112e6[_0x2cecd0(0x1cd)],_0x2cecd0(0x194))+_0x2cecd0(0x1cb)+L(_0x5112e6['to_alias'],'<unknown>')+_0x2cecd0(0x1ca)+_0x1e1b52+_0x2cecd0(0x1d3)+_0x1e83df+_0x2cecd0(0x18f)+L(_0x5112e6[_0x2cecd0(0x1b0)],_0x2cecd0(0x194))+'\x20transport='+_0x5112e6[_0x2cecd0(0x1ba)]+'\x20duration_ms='+_0x5112e6[_0x2cecd0(0x1f5)]+_0x2cecd0(0x1ea)+_0x5112e6[_0x2cecd0(0x1d0)]+_0x1b33ca;}function a0_0xbe4d(){const _0x18b3ad=['application/json,\x20text/event-stream','result','293594XJfJpR','parentTaskId','startsWith','delivered','parse','report_status','now','[REDACTED]','cwd','signal','new_task','\x20network_id=','heartbeatTimer','reconnectDelay','heartbeatInterval','disconnect','<unknown>','error','220818NCEcyU','split','sending','72999AFTSCh','status','sleep','328649gIhkRV','toString','/events/','stringify','695559rteRBQ','call','offline','854020VveXXY','send_failed','data:\x20','min','task.started','token','name','failed','connectSSE','<pending>','sdk','\x20from=',']\x20[commhub:','network_id','165ayXvtG','14OvMOow','content','autoConnect','SSE\x20connected','get_inbox','running','send_rejected','task','transport','Authorization','sseAbort','agent','[commhub:task]\x20','connected','new_message','from_session','AbortError','fromAlias','emit','send','inbox\x20error:\x20','match','decode','POST','\x20task_id=','\x20to=','task.ack','from_alias','catch','Bearer\x20','lifecycle_tracking','networkId','broadcast','\x20parent_task_id=','log','task.send.failed','text','messages','SSE\x20error:\x20','SSE\x20reconnecting\x20in\x20','message','slice','88aLxMBb','CommHub\x20response\x20omitted\x20task_id','alias','connect','/mcp','error_code','resumeId','not_tracked','type','disconnected','text/event-stream','reply','send_message','processInbox','\x20lifecycle=','replace','read','normal','missing_task_id','ack_inbox','idle','SSE\x20failed:\x20','308010RkKMuC','task.replied','message_id','duration_ms','toAlias','8nMwYOd','url','getAllStatus'];a0_0xbe4d=function(){return _0x18b3ad;};return a0_0xbe4d();}function U(_0x443d5a){const _0x5f2337=a0_0x48433c;return{'event':{'sending':'task.send.start','delivered':'task.send.delivered','failed':_0x5f2337(0x1d5),'acked':_0x5f2337(0x1cc),'started':_0x5f2337(0x1a7),'replied':_0x5f2337(0x1f3),'expired':'task.expired'}[_0x443d5a['status']],..._0x443d5a};}function j(_0x2d5dcc){const _0xd8436b=a0_0x48433c;let _0x548b7d=_0x2d5dcc?.['task_id']||_0x2d5dcc?.[_0xd8436b(0x1f4)]||_0x2d5dcc?.['id'];if(_0x548b7d)return String(_0x548b7d);let _0x1e5f66=_0x2d5dcc?.[_0xd8436b(0x1b3)]?.[0x0]?.[_0xd8436b(0x1d6)];if(typeof _0x1e5f66!=='string')return null;try{let _0x3a88b6=JSON['parse'](_0x1e5f66);return _0x3a88b6?.['task_id']||_0x3a88b6?.[_0xd8436b(0x1f4)]||_0x3a88b6?.['id']||null;}catch{return null;}}async function X(_0x4c70b6,_0xe12a0f){const _0x6fc10d=a0_0x48433c;let _0xc9fad1=_0xe12a0f[_0x6fc10d(0x18a)]??Date[_0x6fc10d(0x18a)],_0x27ca03=_0xc9fad1(),_0x128507=(_0x4531d6,_0x3de46c,_0xe9eb4f,_0x2cef04)=>{const _0x462bab=_0x6fc10d;_0xe12a0f['log'](O(U({'from_alias':_0x4c70b6[_0x462bab(0x1c3)],'to_alias':_0x4c70b6[_0x462bab(0x1f6)],'task_id':_0x3de46c,'parent_task_id':_0x4c70b6[_0x462bab(0x185)],'network_id':_0x4c70b6[_0x462bab(0x1d1)],'transport':_0x4c70b6['transport'],'status':_0x4531d6,'duration_ms':_0xc9fad1()-_0x27ca03,'lifecycle_tracking':_0x4c70b6['lifecycleTracking'],..._0xe9eb4f!==void 0x0?{'error_code':_0x2cef04||_0x462bab(0x1a4),'error_message':N(_0xe9eb4f)}:{}})));};_0x128507(_0x6fc10d(0x198),null);try{let _0x1ecd39=await _0xe12a0f['send'](),_0x1b32de=j(_0x1ecd39);if(_0x1b32de)_0x128507(_0x6fc10d(0x187),_0x1b32de);else{if(_0x1ecd39?.['ok']===!0x1||_0x1ecd39?.[_0x6fc10d(0x195)])_0x128507(_0x6fc10d(0x1aa),_0x1b32de,_0x1ecd39?.[_0x6fc10d(0x195)]||'CommHub\x20rejected\x20task',_0x6fc10d(0x1b8));else _0x128507(_0x6fc10d(0x1aa),null,_0x6fc10d(0x1dd),_0x6fc10d(0x1ee));}return _0x1ecd39;}catch(_0x13b6cd){throw _0x128507(_0x6fc10d(0x1aa),null,_0x13b6cd,_0x6fc10d(0x1a4)),_0x13b6cd;}}function a0_0x25c5(_0x3eccf3,_0x49d5ba){_0x3eccf3=_0x3eccf3-0x17f;const _0xbe4da1=a0_0xbe4d();let _0x25c58d=_0xbe4da1[_0x3eccf3];return _0x25c58d;}async function Y(_0x1fcaa8,_0x1d0a6c){const _0x44c82f=a0_0x48433c;return X({'fromAlias':_0x1fcaa8[_0x44c82f(0x1c3)],'toAlias':_0x1fcaa8[_0x44c82f(0x1de)],'parentTaskId':_0x1fcaa8[_0x44c82f(0x185)]||null,'networkId':_0x1fcaa8[_0x44c82f(0x1d1)]||null,'transport':'mcp_http','lifecycleTracking':_0x44c82f(0x1e3)},_0x1d0a6c);}class $ extends a0_0x380af2{[a0_0x48433c(0x180)];[a0_0x48433c(0x1de)];[a0_0x48433c(0x1a8)];[a0_0x48433c(0x1bd)];[a0_0x48433c(0x1e2)];[a0_0x48433c(0x192)];[a0_0x48433c(0x191)];[a0_0x48433c(0x190)];[a0_0x48433c(0x1bc)];[a0_0x48433c(0x1b7)]=!0x1;constructor(_0x14f07d){const _0x1ee3a1=a0_0x48433c;super();if(this[_0x1ee3a1(0x180)]=_0x14f07d[_0x1ee3a1(0x180)][_0x1ee3a1(0x1eb)](/\/$/,''),this[_0x1ee3a1(0x1de)]=_0x14f07d[_0x1ee3a1(0x1de)],this[_0x1ee3a1(0x1a8)]=_0x14f07d[_0x1ee3a1(0x1a8)],this[_0x1ee3a1(0x1bd)]=_0x14f07d[_0x1ee3a1(0x1bd)]||_0x1ee3a1(0x1ad),this[_0x1ee3a1(0x1e2)]='sdk-'+_0x14f07d['alias']+'-'+Date[_0x1ee3a1(0x18a)]()[_0x1ee3a1(0x19d)](0x24),this['heartbeatInterval']=_0x14f07d['heartbeatInterval']??0x2bf20,this[_0x1ee3a1(0x191)]=_0x14f07d[_0x1ee3a1(0x191)]??0xbb8,_0x14f07d[_0x1ee3a1(0x1b4)]!==!0x1)this[_0x1ee3a1(0x1df)]();}[a0_0x48433c(0x1d4)](_0x26730f){const _0xf9f10b=a0_0x48433c;console[_0xf9f10b(0x1d4)]('['+new Date()['toTimeString']()[_0xf9f10b(0x1db)](0x0,0x8)+_0xf9f10b(0x1af)+this[_0xf9f10b(0x1de)]+']\x20'+_0x26730f);}async[a0_0x48433c(0x1a1)](_0x38469f,_0x8003aa){const _0x21c350=a0_0x48433c;let _0x184cbb={'Content-Type':'application/json','Accept':_0x21c350(0x182)};if(this[_0x21c350(0x1a8)])_0x184cbb['Authorization']=_0x21c350(0x1cf)+this[_0x21c350(0x1a8)];let _0x1aa8a8=await(await fetch(this[_0x21c350(0x180)]+_0x21c350(0x1e0),{'method':_0x21c350(0x1c9),'headers':_0x184cbb,'body':JSON[_0x21c350(0x19f)]({'jsonrpc':'2.0','id':Date['now'](),'method':'tools/call','params':{'name':_0x38469f,'arguments':_0x8003aa}})}))[_0x21c350(0x1d6)](),_0x1e6d03=_0x1aa8a8[_0x21c350(0x1c7)](/data: (.+)/),_0x4d9cdc=_0x1e6d03?JSON[_0x21c350(0x188)](_0x1e6d03[0x1]):JSON[_0x21c350(0x188)](_0x1aa8a8),_0x168189=_0x4d9cdc?.[_0x21c350(0x183)]?.[_0x21c350(0x1b3)]?.[0x0]?.['text'];return _0x168189?JSON[_0x21c350(0x188)](_0x168189):_0x4d9cdc;}async[a0_0x48433c(0x1df)](){const _0x5ef9d2=a0_0x48433c;if(this['running'])return;this[_0x5ef9d2(0x1b7)]=!0x0,await this['status']('idle'),this[_0x5ef9d2(0x1d4)]('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x1a596e=_0x5ef9d2;this[_0x1a596e(0x19a)](_0x1a596e(0x1f0))['catch'](_0x2c4857=>this['log']('heartbeat\x20failed:\x20'+_0x2c4857[_0x1a596e(0x1da)]));},this[_0x5ef9d2(0x192)]),this[_0x5ef9d2(0x1ab)]();}async[a0_0x48433c(0x193)](){const _0x117d6f=a0_0x48433c;if(this['running']=!0x1,this[_0x117d6f(0x1bc)]?.['abort'](),this[_0x117d6f(0x190)])clearInterval(this[_0x117d6f(0x190)]);await this[_0x117d6f(0x19a)](_0x117d6f(0x1a2))[_0x117d6f(0x1ce)](()=>{}),this[_0x117d6f(0x1d4)](_0x117d6f(0x1e5));}async[a0_0x48433c(0x1c5)](_0x507688,_0x4d2652,_0x1d9aa9=a0_0x48433c(0x1ed)){const _0x18b33b=a0_0x48433c;return Y({'alias':_0x507688,'fromAlias':this['alias']},{'log':_0x53e914=>console[_0x18b33b(0x1d4)](_0x53e914),'send':()=>this[_0x18b33b(0x1a1)]('send_task',{'alias':_0x507688,'task':_0x4d2652,'priority':_0x1d9aa9,'from_session':this['alias']})});}async[a0_0x48433c(0x1da)](_0x222f0e,_0x2443ac){const _0xd27eb=a0_0x48433c;return this[_0xd27eb(0x1a1)](_0xd27eb(0x1e8),{'alias':_0x222f0e,'message':_0x2443ac,'from_session':this['alias']});}async[a0_0x48433c(0x1e7)](_0x3ee7ff,_0x3b5a09,_0x348637='completed'){return this['call']('send_reply',{'in_reply_to':_0x3ee7ff,'text':_0x3b5a09,'status':_0x348637});}async[a0_0x48433c(0x19a)](_0x19c6f1,_0x3ac224){const _0x39e811=a0_0x48433c;return this[_0x39e811(0x1a1)](_0x39e811(0x189),{'resume_id':this[_0x39e811(0x1e2)],'alias':this['alias'],'status':_0x19c6f1,'server':a0_0x106efe(),'hostname':a0_0x106efe(),'agent':this[_0x39e811(0x1bd)],'project_dir':process[_0x39e811(0x18c)](),..._0x3ac224});}async[a0_0x48433c(0x181)](){return this['call']('get_all_status',{});}async[a0_0x48433c(0x1d2)](_0x415ea4,_0x2a7b72){const _0x88ef61=a0_0x48433c;return this[_0x88ef61(0x1a1)](_0x88ef61(0x1d2),{'message':_0x415ea4,'filter_server':_0x2a7b72?.['server'],'filter_status':_0x2a7b72?.[_0x88ef61(0x19a)]});}async[a0_0x48433c(0x1ab)](){const _0x77362f=a0_0x48433c;let _0x285b8b=encodeURIComponent(this[_0x77362f(0x1de)]),_0x393a6b=this['url']+_0x77362f(0x19e)+_0x285b8b,_0x51c2c8=this[_0x77362f(0x191)];while(this['running']){try{this[_0x77362f(0x1bc)]=new AbortController();let _0x22fca9={'Accept':_0x77362f(0x1e6)};if(this['token'])_0x22fca9[_0x77362f(0x1bb)]='Bearer\x20'+this[_0x77362f(0x1a8)];let _0x31343f=await fetch(_0x393a6b,{'headers':_0x22fca9,'signal':this[_0x77362f(0x1bc)][_0x77362f(0x18d)]});if(!_0x31343f['ok']||!_0x31343f['body']){this['log'](_0x77362f(0x1f1)+_0x31343f['status']),await this[_0x77362f(0x19b)](_0x51c2c8),_0x51c2c8=Math[_0x77362f(0x1a6)](_0x51c2c8*1.5,0xea60);continue;}_0x51c2c8=this[_0x77362f(0x191)];let _0x5a6963=_0x31343f['body']['getReader'](),_0x109d8c=new TextDecoder(),_0x32f459='';while(this[_0x77362f(0x1b7)]){let {done:_0xf4de4e,value:_0x3dd999}=await _0x5a6963[_0x77362f(0x1ec)]();if(_0xf4de4e)break;_0x32f459+=_0x109d8c[_0x77362f(0x1c8)](_0x3dd999,{'stream':!0x0});let _0x296e81=_0x32f459[_0x77362f(0x197)]('\x0a');_0x32f459=_0x296e81['pop']()||'';for(let _0x2ae7a6 of _0x296e81){if(!_0x2ae7a6[_0x77362f(0x186)](_0x77362f(0x1a5)))continue;try{let _0x572285=JSON[_0x77362f(0x188)](_0x2ae7a6[_0x77362f(0x1db)](0x6));if(_0x572285['type']===_0x77362f(0x1bf)){this['log'](_0x77362f(0x1b5)),this[_0x77362f(0x1c4)](_0x77362f(0x1bf));continue;}if(_0x572285[_0x77362f(0x1e4)]===_0x77362f(0x18e)||_0x572285[_0x77362f(0x1e4)]===_0x77362f(0x1c0)||_0x572285[_0x77362f(0x1e4)]===_0x77362f(0x1d2))await this[_0x77362f(0x1e9)]();}catch{}}}}catch(_0x2a2b85){if(_0x2a2b85[_0x77362f(0x1a9)]===_0x77362f(0x1c2))break;this[_0x77362f(0x1c4)]('error',_0x2a2b85),this[_0x77362f(0x1d4)](_0x77362f(0x1d8)+_0x2a2b85[_0x77362f(0x1da)]);}if(this[_0x77362f(0x1b7)])this[_0x77362f(0x1c4)]('disconnected'),this[_0x77362f(0x1d4)](_0x77362f(0x1d9)+_0x51c2c8/0x3e8+'s...'),await this[_0x77362f(0x19b)](_0x51c2c8),_0x51c2c8=Math[_0x77362f(0x1a6)](_0x51c2c8*1.5,0xea60);}}async[a0_0x48433c(0x1e9)](){const _0x4c7a09=a0_0x48433c;try{let _0x21f5e2=(await this[_0x4c7a09(0x1a1)](_0x4c7a09(0x1b6),{'alias':this[_0x4c7a09(0x1de)],'limit':0xa}))?.[_0x4c7a09(0x1d7)]||[];for(let _0x36fefa of _0x21f5e2)await this[_0x4c7a09(0x1a1)](_0x4c7a09(0x1ef),{'alias':this[_0x4c7a09(0x1de)],'message_id':_0x36fefa['id']}),this[_0x4c7a09(0x1d4)]('←\x20'+_0x36fefa[_0x4c7a09(0x1c1)]+':\x20'+_0x36fefa['content'][_0x4c7a09(0x1db)](0x0,0x3c)),this[_0x4c7a09(0x1c4)](_0x4c7a09(0x1b9),_0x36fefa),this[_0x4c7a09(0x1c4)]('message',_0x36fefa);}catch(_0x369a2a){this[_0x4c7a09(0x1d4)](_0x4c7a09(0x1c6)+_0x369a2a[_0x4c7a09(0x1da)]);}}[a0_0x48433c(0x19b)](_0x59db37){return new Promise(_0x4088ea=>setTimeout(_0x4088ea,_0x59db37));}}var F=$;export{F as default,$ as CommHub};
1
+ function a0_0x1fdd(_0x4e8c5d,_0x329a26){_0x4e8c5d=_0x4e8c5d-0x1ed;const _0x24762d=a0_0x2476();let _0x1fdd82=_0x24762d[_0x4e8c5d];return _0x1fdd82;}const a0_0x1ed6e1=a0_0x1fdd;(function(_0x5923c9,_0x4cf399){const _0x128037=a0_0x1fdd,_0x10bd66=_0x5923c9();while(!![]){try{const _0x40e898=-parseInt(_0x128037(0x210))/0x1+parseInt(_0x128037(0x22b))/0x2+-parseInt(_0x128037(0x266))/0x3+-parseInt(_0x128037(0x1fa))/0x4*(-parseInt(_0x128037(0x219))/0x5)+-parseInt(_0x128037(0x225))/0x6+parseInt(_0x128037(0x26b))/0x7*(-parseInt(_0x128037(0x221))/0x8)+parseInt(_0x128037(0x23b))/0x9;if(_0x40e898===_0x4cf399)break;else _0x10bd66['push'](_0x10bd66['shift']());}catch(_0x136b21){_0x10bd66['push'](_0x10bd66['shift']());}}}(a0_0x2476,0x482d9));import{EventEmitter as a0_0x5b76af}from'events';import{hostname as a0_0x245c96}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x59fd56,_0x100225)=>(_0x59fd56??_0x100225)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x886d72){const _0x5ce3f9=a0_0x1fdd;return(_0x886d72 instanceof Error?_0x886d72[_0x5ce3f9(0x259)]:String(_0x886d72??_0x5ce3f9(0x254)))['replace'](K,_0x5ce3f9(0x268))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5ce3f9(0x23e)](0x0,0xf0);}function O(_0x3dbac0,_0x399967=process.env.ANET_TASK_TRACE_FORMAT===a0_0x1ed6e1(0x263)){const _0x5159c3=a0_0x1ed6e1;if(_0x399967)return JSON[_0x5159c3(0x21d)](_0x3dbac0);let _0x37575c=L(_0x3dbac0['parent_task_id'],_0x5159c3(0x243)),_0x2e5632=L(_0x3dbac0[_0x5159c3(0x24b)],'<pending>'),_0x55204d=_0x3dbac0[_0x5159c3(0x1fd)]?'\x20error='+_0x3dbac0['error_code']+':'+(_0x3dbac0[_0x5159c3(0x247)]??''):'';return _0x5159c3(0x24d)+_0x3dbac0[_0x5159c3(0x205)]+_0x5159c3(0x229)+L(_0x3dbac0[_0x5159c3(0x1fc)],_0x5159c3(0x216))+_0x5159c3(0x204)+L(_0x3dbac0[_0x5159c3(0x237)],_0x5159c3(0x216))+_0x5159c3(0x220)+_0x2e5632+_0x5159c3(0x23d)+_0x37575c+_0x5159c3(0x1f7)+L(_0x3dbac0[_0x5159c3(0x1ef)],_0x5159c3(0x216))+'\x20transport='+_0x3dbac0[_0x5159c3(0x242)]+_0x5159c3(0x236)+_0x3dbac0[_0x5159c3(0x241)]+_0x5159c3(0x1f3)+_0x3dbac0[_0x5159c3(0x1fe)]+_0x55204d;}function U(_0x5cd0d3){const _0x502992=a0_0x1ed6e1;return{'event':{'sending':_0x502992(0x25d),'delivered':_0x502992(0x227),'failed':_0x502992(0x1f1),'acked':_0x502992(0x22d),'started':_0x502992(0x26c),'replied':_0x502992(0x200),'expired':_0x502992(0x20b)}[_0x5cd0d3[_0x502992(0x205)]],..._0x5cd0d3};}function j(_0x78031f){const _0x57a560=a0_0x1ed6e1;let _0x3dff66=_0x78031f?.[_0x57a560(0x24b)]||_0x78031f?.[_0x57a560(0x264)]||_0x78031f?.['id'];if(_0x3dff66)return String(_0x3dff66);let _0x31c6d8=_0x78031f?.[_0x57a560(0x25b)]?.[0x0]?.['text'];if(typeof _0x31c6d8!=='string')return null;try{let _0x2062fc=JSON['parse'](_0x31c6d8);return _0x2062fc?.[_0x57a560(0x24b)]||_0x2062fc?.['message_id']||_0x2062fc?.['id']||null;}catch{return null;}}function a0_0x2476(){const _0x5bce8c=['\x20from=','CommHub\x20response\x20omitted\x20task_id','711284DkCCye','broadcast','task.ack','completed','offline','data:\x20','connected','sleep','new_message','text','toString','\x20duration_ms=','to_alias','get_all_status','connect','heartbeatTimer','7680429KMiEWO','from_session','\x20parent_task_id=','slice','call','AbortError','duration_ms','transport','<missing>','autoConnect','abort','lifecycleTracking','error_message','server','inbox\x20error:\x20','decode','task_id','toAlias','[commhub:task]\x20','application/json','SSE\x20reconnecting\x20in\x20','replace','type','heartbeatInterval','SSE\x20error:\x20','unknown\x20error','catch','signal','send_failed','match','message','min','content','idle','task.send.start','task','cwd','tools/call','CommHub\x20rejected\x20task','heartbeat\x20failed:\x20','json','message_id','alias','1074717DhrPzh','running','[REDACTED]','2.0','connectSSE','961268ZsvVYq','task.started','read','messages','log','body','emit','get_inbox','network_id','Authorization','task.send.failed','agent','\x20lifecycle=','reconnectDelay','url','registered','\x20network_id=','sdk','now','12qFRHiH','POST','from_alias','error_code','lifecycle_tracking','processInbox','task.replied','send_reply','fromAlias','parentTaskId','\x20to=','status','sdk-','sending','Bearer\x20','normal','error','task.expired','sseAbort','send','disconnect','resumeId','298704UxxlUx','send_message','s...','failed','ack_inbox','missing_task_id','<unknown>','split',']\x20[commhub:','20685PnRWin','token','getAllStatus','networkId','stringify','report_status','send_task','\x20task_id=','8kDBGUE','disconnected','getReader','parse','789156mYavUc','toTimeString','task.send.delivered','pop'];a0_0x2476=function(){return _0x5bce8c;};return a0_0x2476();}async function X(_0x44cbd7,_0x487004){const _0x4432a3=a0_0x1ed6e1;let _0x5eb6f5=_0x487004[_0x4432a3(0x1f9)]??Date[_0x4432a3(0x1f9)],_0xe13c27=_0x5eb6f5(),_0x48b829=(_0x5132ec,_0xaebd78,_0x4bd0a5,_0x17e4ed)=>{const _0xc90d73=_0x4432a3;_0x487004[_0xc90d73(0x26f)](O(U({'from_alias':_0x44cbd7[_0xc90d73(0x202)],'to_alias':_0x44cbd7[_0xc90d73(0x24c)],'task_id':_0xaebd78,'parent_task_id':_0x44cbd7[_0xc90d73(0x203)],'network_id':_0x44cbd7[_0xc90d73(0x21c)],'transport':_0x44cbd7[_0xc90d73(0x242)],'status':_0x5132ec,'duration_ms':_0x5eb6f5()-_0xe13c27,'lifecycle_tracking':_0x44cbd7[_0xc90d73(0x246)],..._0x4bd0a5!==void 0x0?{'error_code':_0x17e4ed||_0xc90d73(0x257),'error_message':N(_0x4bd0a5)}:{}})));};_0x48b829(_0x4432a3(0x207),null);try{let _0x462a99=await _0x487004[_0x4432a3(0x20d)](),_0x1b4038=j(_0x462a99);if(_0x1b4038)_0x48b829('delivered',_0x1b4038);else{if(_0x462a99?.['ok']===!0x1||_0x462a99?.[_0x4432a3(0x20a)])_0x48b829('failed',_0x1b4038,_0x462a99?.[_0x4432a3(0x20a)]||_0x4432a3(0x261),'send_rejected');else _0x48b829(_0x4432a3(0x213),null,_0x4432a3(0x22a),_0x4432a3(0x215));}return _0x462a99;}catch(_0x3d873b){throw _0x48b829('failed',null,_0x3d873b,_0x4432a3(0x257)),_0x3d873b;}}async function Y(_0x24a1bf,_0x4a6e05){const _0x388fca=a0_0x1ed6e1;return X({'fromAlias':_0x24a1bf[_0x388fca(0x202)],'toAlias':_0x24a1bf[_0x388fca(0x265)],'parentTaskId':_0x24a1bf[_0x388fca(0x203)]||null,'networkId':_0x24a1bf['networkId']||null,'transport':'mcp_http','lifecycleTracking':'not_tracked'},_0x4a6e05);}class $ extends a0_0x5b76af{[a0_0x1ed6e1(0x1f5)];[a0_0x1ed6e1(0x265)];['token'];[a0_0x1ed6e1(0x1f2)];[a0_0x1ed6e1(0x20f)];['heartbeatInterval'];[a0_0x1ed6e1(0x1f4)];[a0_0x1ed6e1(0x23a)];[a0_0x1ed6e1(0x20c)];[a0_0x1ed6e1(0x267)]=!0x1;constructor(_0x4897ed){const _0x952867=a0_0x1ed6e1;super();if(this['url']=_0x4897ed[_0x952867(0x1f5)][_0x952867(0x250)](/\/$/,''),this['alias']=_0x4897ed[_0x952867(0x265)],this[_0x952867(0x21a)]=_0x4897ed['token'],this[_0x952867(0x1f2)]=_0x4897ed['agent']||_0x952867(0x1f8),this[_0x952867(0x20f)]=_0x952867(0x206)+_0x4897ed[_0x952867(0x265)]+'-'+Date[_0x952867(0x1f9)]()[_0x952867(0x235)](0x24),this['heartbeatInterval']=_0x4897ed[_0x952867(0x252)]??0x2bf20,this[_0x952867(0x1f4)]=_0x4897ed[_0x952867(0x1f4)]??0xbb8,_0x4897ed[_0x952867(0x244)]!==!0x1)this['connect']();}[a0_0x1ed6e1(0x26f)](_0x410abe){const _0x38e3c6=a0_0x1ed6e1;console[_0x38e3c6(0x26f)]('['+new Date()[_0x38e3c6(0x226)]()[_0x38e3c6(0x23e)](0x0,0x8)+_0x38e3c6(0x218)+this['alias']+']\x20'+_0x410abe);}async[a0_0x1ed6e1(0x23f)](_0x326279,_0x38121d){const _0x25079a=a0_0x1ed6e1;let _0x4919ee={'Content-Type':_0x25079a(0x24e),'Accept':'application/json,\x20text/event-stream'};if(this[_0x25079a(0x21a)])_0x4919ee['Authorization']='Bearer\x20'+this[_0x25079a(0x21a)];let _0x33455c=await(await fetch(this['url']+'/mcp',{'method':_0x25079a(0x1fb),'headers':_0x4919ee,'body':JSON['stringify']({'jsonrpc':_0x25079a(0x269),'id':Date[_0x25079a(0x1f9)](),'method':_0x25079a(0x260),'params':{'name':_0x326279,'arguments':_0x38121d}})}))['text'](),_0x16f46c=_0x33455c[_0x25079a(0x258)](/data: (.+)/),_0x249da6=_0x16f46c?JSON[_0x25079a(0x224)](_0x16f46c[0x1]):JSON[_0x25079a(0x224)](_0x33455c),_0x3f26e5=_0x249da6?.['result']?.['content']?.[0x0]?.[_0x25079a(0x234)];return _0x3f26e5?JSON['parse'](_0x3f26e5):_0x249da6;}async[a0_0x1ed6e1(0x239)](){const _0x394c2f=a0_0x1ed6e1;if(this[_0x394c2f(0x267)])return;this[_0x394c2f(0x267)]=!0x0,await this[_0x394c2f(0x205)]('idle'),this[_0x394c2f(0x26f)](_0x394c2f(0x1f6)),this['heartbeatTimer']=setInterval(()=>{const _0x32f587=_0x394c2f;this[_0x32f587(0x205)](_0x32f587(0x25c))[_0x32f587(0x255)](_0x3c1804=>this[_0x32f587(0x26f)](_0x32f587(0x262)+_0x3c1804[_0x32f587(0x259)]));},this[_0x394c2f(0x252)]),this[_0x394c2f(0x26a)]();}async[a0_0x1ed6e1(0x20e)](){const _0x396c2d=a0_0x1ed6e1;if(this[_0x396c2d(0x267)]=!0x1,this['sseAbort']?.[_0x396c2d(0x245)](),this[_0x396c2d(0x23a)])clearInterval(this[_0x396c2d(0x23a)]);await this[_0x396c2d(0x205)](_0x396c2d(0x22f))['catch'](()=>{}),this[_0x396c2d(0x26f)]('disconnected');}async['send'](_0x4c7d46,_0x3b9a07,_0x479949=a0_0x1ed6e1(0x209)){const _0x5e173a=a0_0x1ed6e1;return Y({'alias':_0x4c7d46,'fromAlias':this[_0x5e173a(0x265)]},{'log':_0x414a92=>console[_0x5e173a(0x26f)](_0x414a92),'send':()=>this[_0x5e173a(0x23f)](_0x5e173a(0x21f),{'alias':_0x4c7d46,'task':_0x3b9a07,'priority':_0x479949,'from_session':this[_0x5e173a(0x265)]})});}async[a0_0x1ed6e1(0x259)](_0xe12d08,_0xc54351){const _0x21f94c=a0_0x1ed6e1;return this[_0x21f94c(0x23f)](_0x21f94c(0x211),{'alias':_0xe12d08,'message':_0xc54351,'from_session':this[_0x21f94c(0x265)]});}async['reply'](_0x114309,_0x21559e,_0x1d6fb2=a0_0x1ed6e1(0x22e)){const _0x184ae5=a0_0x1ed6e1;return this['call'](_0x184ae5(0x201),{'in_reply_to':_0x114309,'text':_0x21559e,'status':_0x1d6fb2});}async['status'](_0x3fc33a,_0x237582){const _0x26dbf1=a0_0x1ed6e1;return this[_0x26dbf1(0x23f)](_0x26dbf1(0x21e),{'resume_id':this[_0x26dbf1(0x20f)],'alias':this[_0x26dbf1(0x265)],'status':_0x3fc33a,'server':a0_0x245c96(),'hostname':a0_0x245c96(),'agent':this[_0x26dbf1(0x1f2)],'project_dir':process[_0x26dbf1(0x25f)](),..._0x237582});}async[a0_0x1ed6e1(0x21b)](){const _0x15a7bf=a0_0x1ed6e1;return this[_0x15a7bf(0x23f)](_0x15a7bf(0x238),{});}async[a0_0x1ed6e1(0x22c)](_0x255dc0,_0xa20cdc){const _0x4798b0=a0_0x1ed6e1;return this['call'](_0x4798b0(0x22c),{'message':_0x255dc0,'filter_server':_0xa20cdc?.[_0x4798b0(0x248)],'filter_status':_0xa20cdc?.['status']});}async['connectSSE'](){const _0x50e20b=a0_0x1ed6e1;let _0x23034e=encodeURIComponent(this[_0x50e20b(0x265)]),_0x39059e=this[_0x50e20b(0x1f5)]+'/events/'+_0x23034e,_0x258ebb=this['reconnectDelay'];while(this[_0x50e20b(0x267)]){try{this[_0x50e20b(0x20c)]=new AbortController();let _0x9ae965={'Accept':'text/event-stream'};if(this[_0x50e20b(0x21a)])_0x9ae965[_0x50e20b(0x1f0)]=_0x50e20b(0x208)+this['token'];let _0x549bf8=await fetch(_0x39059e,{'headers':_0x9ae965,'signal':this[_0x50e20b(0x20c)][_0x50e20b(0x256)]});if(!_0x549bf8['ok']||!_0x549bf8[_0x50e20b(0x270)]){this[_0x50e20b(0x26f)]('SSE\x20failed:\x20'+_0x549bf8[_0x50e20b(0x205)]),await this[_0x50e20b(0x232)](_0x258ebb),_0x258ebb=Math['min'](_0x258ebb*1.5,0xea60);continue;}_0x258ebb=this[_0x50e20b(0x1f4)];let _0x48c5ff=_0x549bf8['body'][_0x50e20b(0x223)](),_0x95fee2=new TextDecoder(),_0x168805='';while(this[_0x50e20b(0x267)]){let {done:_0x1bd773,value:_0x7b4e6e}=await _0x48c5ff[_0x50e20b(0x26d)]();if(_0x1bd773)break;_0x168805+=_0x95fee2[_0x50e20b(0x24a)](_0x7b4e6e,{'stream':!0x0});let _0x9e9274=_0x168805[_0x50e20b(0x217)]('\x0a');_0x168805=_0x9e9274[_0x50e20b(0x228)]()||'';for(let _0x21bda4 of _0x9e9274){if(!_0x21bda4['startsWith'](_0x50e20b(0x230)))continue;try{let _0x254fd4=JSON[_0x50e20b(0x224)](_0x21bda4['slice'](0x6));if(_0x254fd4['type']===_0x50e20b(0x231)){this[_0x50e20b(0x26f)]('SSE\x20connected'),this[_0x50e20b(0x1ed)]('connected');continue;}if(_0x254fd4[_0x50e20b(0x251)]==='new_task'||_0x254fd4[_0x50e20b(0x251)]===_0x50e20b(0x233)||_0x254fd4[_0x50e20b(0x251)]===_0x50e20b(0x22c))await this[_0x50e20b(0x1ff)]();}catch{}}}}catch(_0x496833){if(_0x496833['name']===_0x50e20b(0x240))break;this[_0x50e20b(0x1ed)]('error',_0x496833),this[_0x50e20b(0x26f)](_0x50e20b(0x253)+_0x496833['message']);}if(this[_0x50e20b(0x267)])this[_0x50e20b(0x1ed)](_0x50e20b(0x222)),this[_0x50e20b(0x26f)](_0x50e20b(0x24f)+_0x258ebb/0x3e8+_0x50e20b(0x212)),await this[_0x50e20b(0x232)](_0x258ebb),_0x258ebb=Math[_0x50e20b(0x25a)](_0x258ebb*1.5,0xea60);}}async[a0_0x1ed6e1(0x1ff)](){const _0x2a4e3e=a0_0x1ed6e1;try{let _0x323ffe=(await this['call'](_0x2a4e3e(0x1ee),{'alias':this[_0x2a4e3e(0x265)],'limit':0xa}))?.[_0x2a4e3e(0x26e)]||[];for(let _0x3465ee of _0x323ffe)await this['call'](_0x2a4e3e(0x214),{'alias':this['alias'],'message_id':_0x3465ee['id']}),this[_0x2a4e3e(0x26f)]('←\x20'+_0x3465ee[_0x2a4e3e(0x23c)]+':\x20'+_0x3465ee[_0x2a4e3e(0x25b)][_0x2a4e3e(0x23e)](0x0,0x3c)),this[_0x2a4e3e(0x1ed)](_0x2a4e3e(0x25e),_0x3465ee),this[_0x2a4e3e(0x1ed)]('message',_0x3465ee);}catch(_0x6c91dc){this[_0x2a4e3e(0x26f)](_0x2a4e3e(0x249)+_0x6c91dc['message']);}}[a0_0x1ed6e1(0x232)](_0x5c55e7){return new Promise(_0x3fcf97=>setTimeout(_0x3fcf97,_0x5c55e7));}}var F=$;export{F as default,$ as CommHub};