@sleep2agi/agent-network 2.3.0-preview.50 → 2.3.0-preview.51
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_0x2b779f=a0_0x4ece;(function(_0x33dff6,_0x800a3e){const _0x4cbabb=a0_0x4ece,_0x581bce=_0x33dff6();while(!![]){try{const _0x27f1ab=-parseInt(_0x4cbabb(0x21b))/0x1*(-parseInt(_0x4cbabb(0x254))/0x2)+parseInt(_0x4cbabb(0x1ff))/0x3*(parseInt(_0x4cbabb(0x1fc))/0x4)+parseInt(_0x4cbabb(0x242))/0x5*(parseInt(_0x4cbabb(0x1f4))/0x6)+parseInt(_0x4cbabb(0x25a))/0x7*(-parseInt(_0x4cbabb(0x1ea))/0x8)+parseInt(_0x4cbabb(0x20f))/0x9+-parseInt(_0x4cbabb(0x25c))/0xa*(parseInt(_0x4cbabb(0x24c))/0xb)+-parseInt(_0x4cbabb(0x23e))/0xc;if(_0x27f1ab===_0x800a3e)break;else _0x581bce['push'](_0x581bce['shift']());}catch(_0x525195){_0x581bce['push'](_0x581bce['shift']());}}}(a0_0x47b1,0xc4bf1));function a0_0x47b1(){const _0x5b081c=[']\x20[commhub:','signal','12459573wrQwkW','result','json','<missing>','string','message_id','fromAlias','failed','parse','agent','call','data:\x20','1zPjjgd','stringify','2.0','split','connectSSE','from_session','send_failed','broadcast','processInbox','\x20to=','error_code','heartbeatTimer','idle','get_all_status','task_id','toTimeString','resumeId','reply','emit','sdk','reconnectDelay','name','connected','completed','send','<unknown>','transport','url','body','heartbeatInterval','AbortError','content','message','SSE\x20reconnecting\x20in\x20','alias','30442920AsmCoO','application/json','sending','<pending>','851470dYXNFq','slice','sdk-','server','new_task','sseAbort','unknown\x20error','running','\x20from=','send_message','11bXZBjS','task','CommHub\x20response\x20omitted\x20task_id','normal','Bearer\x20','missing_task_id','task.send.start','\x20parent_task_id=','1455124AwkmyA','send_rejected','networkId','disconnected','Authorization','\x20transport=','2912pghnVo','sleep','664270TVAAWz','autoConnect','error_message','registered','task.send.failed','now','CommHub\x20rejected\x20task','status','\x20error=','not_tracked','tools/call','parent_task_id','startsWith','delivered','6776RelsAe','toAlias','duration_ms','read','\x20duration_ms=','cwd','min','\x20lifecycle=','disconnect','inbox\x20error:\x20','18YRCXLQ','getAllStatus','task.expired','application/json,\x20text/event-stream','connect','/mcp','error','text','628sCFUjC','task.started','SSE\x20failed:\x20','21759pofOfW','catch','to_alias','offline','task.replied','log','type','pop','s...','token','\x20task_id=','from_alias','parentTaskId','replace'];a0_0x47b1=function(){return _0x5b081c;};return a0_0x47b1();}import{EventEmitter as a0_0x181164}from'events';import{hostname as a0_0x2f50b2}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x57501c,_0xe54201)=>(_0x57501c??_0xe54201)[a0_0x2b779f(0x20c)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x490806){const _0xbf88f6=a0_0x2b779f;return(_0x490806 instanceof Error?_0x490806['message']:String(_0x490806??_0xbf88f6(0x248)))['replace'](K,'[REDACTED]')[_0xbf88f6(0x20c)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x2d2397,_0x3a60f7=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2b779f(0x211)){const _0x49bb4a=a0_0x2b779f;if(_0x3a60f7)return JSON[_0x49bb4a(0x21c)](_0x2d2397);let _0x4d0ec9=L(_0x2d2397[_0x49bb4a(0x1e7)],_0x49bb4a(0x212)),_0x241605=L(_0x2d2397[_0x49bb4a(0x229)],_0x49bb4a(0x241)),_0x3d170e=_0x2d2397['error_code']?_0x49bb4a(0x1e4)+_0x2d2397[_0x49bb4a(0x225)]+':'+(_0x2d2397[_0x49bb4a(0x25e)]??''):'';return'[commhub:task]\x20'+_0x2d2397[_0x49bb4a(0x1e3)]+_0x49bb4a(0x24a)+L(_0x2d2397[_0x49bb4a(0x20a)],'<unknown>')+_0x49bb4a(0x224)+L(_0x2d2397[_0x49bb4a(0x201)],_0x49bb4a(0x234))+_0x49bb4a(0x209)+_0x241605+_0x49bb4a(0x253)+_0x4d0ec9+'\x20network_id='+L(_0x2d2397['network_id'],_0x49bb4a(0x234))+_0x49bb4a(0x259)+_0x2d2397['transport']+_0x49bb4a(0x1ee)+_0x2d2397[_0x49bb4a(0x1ec)]+_0x49bb4a(0x1f1)+_0x2d2397['lifecycle_tracking']+_0x3d170e;}function U(_0x3d3213){const _0x14a1d2=a0_0x2b779f;return{'event':{'sending':_0x14a1d2(0x252),'delivered':'task.send.delivered','failed':_0x14a1d2(0x260),'acked':'task.ack','started':_0x14a1d2(0x1fd),'replied':_0x14a1d2(0x203),'expired':_0x14a1d2(0x1f6)}[_0x3d3213['status']],..._0x3d3213};}function j(_0x18fe2c){const _0x1c050d=a0_0x2b779f;let _0xa7f551=_0x18fe2c?.[_0x1c050d(0x229)]||_0x18fe2c?.[_0x1c050d(0x214)]||_0x18fe2c?.['id'];if(_0xa7f551)return String(_0xa7f551);let _0x246e0a=_0x18fe2c?.[_0x1c050d(0x23a)]?.[0x0]?.['text'];if(typeof _0x246e0a!==_0x1c050d(0x213))return null;try{let _0x477b19=JSON['parse'](_0x246e0a);return _0x477b19?.[_0x1c050d(0x229)]||_0x477b19?.[_0x1c050d(0x214)]||_0x477b19?.['id']||null;}catch{return null;}}async function X(_0x4964e9,_0x4c9477){const _0x5e5941=a0_0x2b779f;let _0x484139=_0x4c9477[_0x5e5941(0x261)]??Date[_0x5e5941(0x261)],_0x3a1d92=_0x484139(),_0x1d7be1=(_0x1fc045,_0x533a3c,_0x5d57d4,_0x4eb632)=>{const _0x21a1b0=_0x5e5941;_0x4c9477[_0x21a1b0(0x204)](O(U({'from_alias':_0x4964e9['fromAlias'],'to_alias':_0x4964e9[_0x21a1b0(0x1eb)],'task_id':_0x533a3c,'parent_task_id':_0x4964e9[_0x21a1b0(0x20b)],'network_id':_0x4964e9[_0x21a1b0(0x256)],'transport':_0x4964e9[_0x21a1b0(0x235)],'status':_0x1fc045,'duration_ms':_0x484139()-_0x3a1d92,'lifecycle_tracking':_0x4964e9['lifecycleTracking'],..._0x5d57d4!==void 0x0?{'error_code':_0x4eb632||_0x21a1b0(0x221),'error_message':N(_0x5d57d4)}:{}})));};_0x1d7be1(_0x5e5941(0x240),null);try{let _0x3b332a=await _0x4c9477[_0x5e5941(0x233)](),_0x4241c5=j(_0x3b332a);if(_0x4241c5)_0x1d7be1(_0x5e5941(0x1e9),_0x4241c5);else{if(_0x3b332a?.['ok']===!0x1||_0x3b332a?.[_0x5e5941(0x1fa)])_0x1d7be1('failed',_0x4241c5,_0x3b332a?.[_0x5e5941(0x1fa)]||_0x5e5941(0x1e2),_0x5e5941(0x255));else _0x1d7be1(_0x5e5941(0x216),null,_0x5e5941(0x24e),_0x5e5941(0x251));}return _0x3b332a;}catch(_0x37fafe){throw _0x1d7be1(_0x5e5941(0x216),null,_0x37fafe,_0x5e5941(0x221)),_0x37fafe;}}async function Y(_0x402726,_0x5f418d){const _0x4e70a0=a0_0x2b779f;return X({'fromAlias':_0x402726[_0x4e70a0(0x215)],'toAlias':_0x402726['alias'],'parentTaskId':_0x402726['parentTaskId']||null,'networkId':_0x402726['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x4e70a0(0x1e5)},_0x5f418d);}class $ extends a0_0x181164{[a0_0x2b779f(0x236)];[a0_0x2b779f(0x23d)];[a0_0x2b779f(0x208)];[a0_0x2b779f(0x218)];[a0_0x2b779f(0x22b)];[a0_0x2b779f(0x238)];[a0_0x2b779f(0x22f)];[a0_0x2b779f(0x226)];['sseAbort'];[a0_0x2b779f(0x249)]=!0x1;constructor(_0x1c10e4){const _0x3c3c18=a0_0x2b779f;super();if(this['url']=_0x1c10e4[_0x3c3c18(0x236)]['replace'](/\/$/,''),this['alias']=_0x1c10e4[_0x3c3c18(0x23d)],this[_0x3c3c18(0x208)]=_0x1c10e4[_0x3c3c18(0x208)],this[_0x3c3c18(0x218)]=_0x1c10e4[_0x3c3c18(0x218)]||_0x3c3c18(0x22e),this[_0x3c3c18(0x22b)]=_0x3c3c18(0x244)+_0x1c10e4[_0x3c3c18(0x23d)]+'-'+Date[_0x3c3c18(0x261)]()['toString'](0x24),this[_0x3c3c18(0x238)]=_0x1c10e4[_0x3c3c18(0x238)]??0x2bf20,this[_0x3c3c18(0x22f)]=_0x1c10e4[_0x3c3c18(0x22f)]??0xbb8,_0x1c10e4[_0x3c3c18(0x25d)]!==!0x1)this[_0x3c3c18(0x1f8)]();}[a0_0x2b779f(0x204)](_0x26eeaa){const _0x416f61=a0_0x2b779f;console[_0x416f61(0x204)]('['+new Date()[_0x416f61(0x22a)]()[_0x416f61(0x243)](0x0,0x8)+_0x416f61(0x20d)+this['alias']+']\x20'+_0x26eeaa);}async[a0_0x2b779f(0x219)](_0x20c518,_0x55a6ea){const _0x23b090=a0_0x2b779f;let _0x103ab8={'Content-Type':_0x23b090(0x23f),'Accept':_0x23b090(0x1f7)};if(this[_0x23b090(0x208)])_0x103ab8[_0x23b090(0x258)]=_0x23b090(0x250)+this[_0x23b090(0x208)];let _0x301545=await(await fetch(this[_0x23b090(0x236)]+_0x23b090(0x1f9),{'method':'POST','headers':_0x103ab8,'body':JSON['stringify']({'jsonrpc':_0x23b090(0x21d),'id':Date[_0x23b090(0x261)](),'method':_0x23b090(0x1e6),'params':{'name':_0x20c518,'arguments':_0x55a6ea}})}))[_0x23b090(0x1fb)](),_0x544d3a=_0x301545['match'](/data: (.+)/),_0x3dd80f=_0x544d3a?JSON[_0x23b090(0x217)](_0x544d3a[0x1]):JSON[_0x23b090(0x217)](_0x301545),_0x59ea66=_0x3dd80f?.[_0x23b090(0x210)]?.[_0x23b090(0x23a)]?.[0x0]?.[_0x23b090(0x1fb)];return _0x59ea66?JSON[_0x23b090(0x217)](_0x59ea66):_0x3dd80f;}async['connect'](){const _0x5dd280=a0_0x2b779f;if(this[_0x5dd280(0x249)])return;this[_0x5dd280(0x249)]=!0x0,await this[_0x5dd280(0x1e3)]('idle'),this[_0x5dd280(0x204)](_0x5dd280(0x25f)),this[_0x5dd280(0x226)]=setInterval(()=>{const _0x3ec35a=_0x5dd280;this[_0x3ec35a(0x1e3)](_0x3ec35a(0x227))[_0x3ec35a(0x200)](_0x5d63f5=>this['log']('heartbeat\x20failed:\x20'+_0x5d63f5[_0x3ec35a(0x23b)]));},this[_0x5dd280(0x238)]),this[_0x5dd280(0x21f)]();}async[a0_0x2b779f(0x1f2)](){const _0x393368=a0_0x2b779f;if(this['running']=!0x1,this[_0x393368(0x247)]?.['abort'](),this[_0x393368(0x226)])clearInterval(this['heartbeatTimer']);await this[_0x393368(0x1e3)](_0x393368(0x202))[_0x393368(0x200)](()=>{}),this[_0x393368(0x204)]('disconnected');}async[a0_0x2b779f(0x233)](_0x3efe6d,_0x36f785,_0xa97aa8=a0_0x2b779f(0x24f)){const _0x372f1d=a0_0x2b779f;return Y({'alias':_0x3efe6d,'fromAlias':this[_0x372f1d(0x23d)]},{'log':_0x447162=>console[_0x372f1d(0x204)](_0x447162),'send':()=>this[_0x372f1d(0x219)]('send_task',{'alias':_0x3efe6d,'task':_0x36f785,'priority':_0xa97aa8,'from_session':this['alias']})});}async['message'](_0x4ccd32,_0x4aec71){const _0x4de587=a0_0x2b779f;return this['call'](_0x4de587(0x24b),{'alias':_0x4ccd32,'message':_0x4aec71,'from_session':this['alias']});}async[a0_0x2b779f(0x22c)](_0x21845b,_0xcfac8a,_0xdf6037=a0_0x2b779f(0x232)){return this['call']('send_reply',{'in_reply_to':_0x21845b,'text':_0xcfac8a,'status':_0xdf6037});}async[a0_0x2b779f(0x1e3)](_0x28c5b4,_0x23eb94){const _0x137cc0=a0_0x2b779f;return this['call']('report_status',{'resume_id':this[_0x137cc0(0x22b)],'alias':this['alias'],'status':_0x28c5b4,'server':a0_0x2f50b2(),'hostname':a0_0x2f50b2(),'agent':this[_0x137cc0(0x218)],'project_dir':process[_0x137cc0(0x1ef)](),..._0x23eb94});}async[a0_0x2b779f(0x1f5)](){const _0x329956=a0_0x2b779f;return this[_0x329956(0x219)](_0x329956(0x228),{});}async[a0_0x2b779f(0x222)](_0x5ac6f6,_0x45bb3b){const _0x1866a9=a0_0x2b779f;return this[_0x1866a9(0x219)](_0x1866a9(0x222),{'message':_0x5ac6f6,'filter_server':_0x45bb3b?.[_0x1866a9(0x245)],'filter_status':_0x45bb3b?.[_0x1866a9(0x1e3)]});}async['connectSSE'](){const _0x335cc6=a0_0x2b779f;let _0x5650bc=encodeURIComponent(this[_0x335cc6(0x23d)]),_0x5d7ea9=this[_0x335cc6(0x236)]+'/events/'+_0x5650bc,_0x487e7f=this[_0x335cc6(0x22f)];while(this[_0x335cc6(0x249)]){try{this[_0x335cc6(0x247)]=new AbortController();let _0x2dd40c={'Accept':'text/event-stream'};if(this[_0x335cc6(0x208)])_0x2dd40c[_0x335cc6(0x258)]=_0x335cc6(0x250)+this[_0x335cc6(0x208)];let _0x1734bb=await fetch(_0x5d7ea9,{'headers':_0x2dd40c,'signal':this[_0x335cc6(0x247)][_0x335cc6(0x20e)]});if(!_0x1734bb['ok']||!_0x1734bb[_0x335cc6(0x237)]){this[_0x335cc6(0x204)](_0x335cc6(0x1fe)+_0x1734bb[_0x335cc6(0x1e3)]),await this[_0x335cc6(0x25b)](_0x487e7f),_0x487e7f=Math[_0x335cc6(0x1f0)](_0x487e7f*1.5,0xea60);continue;}_0x487e7f=this[_0x335cc6(0x22f)];let _0x2e4811=_0x1734bb['body']['getReader'](),_0x21fbc2=new TextDecoder(),_0x5d3af1='';while(this[_0x335cc6(0x249)]){let {done:_0x57543c,value:_0x3d9a04}=await _0x2e4811[_0x335cc6(0x1ed)]();if(_0x57543c)break;_0x5d3af1+=_0x21fbc2['decode'](_0x3d9a04,{'stream':!0x0});let _0x3b2a13=_0x5d3af1[_0x335cc6(0x21e)]('\x0a');_0x5d3af1=_0x3b2a13[_0x335cc6(0x206)]()||'';for(let _0xcaf418 of _0x3b2a13){if(!_0xcaf418[_0x335cc6(0x1e8)](_0x335cc6(0x21a)))continue;try{let _0x2f6d13=JSON[_0x335cc6(0x217)](_0xcaf418[_0x335cc6(0x243)](0x6));if(_0x2f6d13[_0x335cc6(0x205)]===_0x335cc6(0x231)){this['log']('SSE\x20connected'),this[_0x335cc6(0x22d)](_0x335cc6(0x231));continue;}if(_0x2f6d13[_0x335cc6(0x205)]===_0x335cc6(0x246)||_0x2f6d13['type']==='new_message'||_0x2f6d13[_0x335cc6(0x205)]===_0x335cc6(0x222))await this['processInbox']();}catch{}}}}catch(_0x1472db){if(_0x1472db[_0x335cc6(0x230)]===_0x335cc6(0x239))break;this[_0x335cc6(0x22d)](_0x335cc6(0x1fa),_0x1472db),this[_0x335cc6(0x204)]('SSE\x20error:\x20'+_0x1472db['message']);}if(this[_0x335cc6(0x249)])this[_0x335cc6(0x22d)](_0x335cc6(0x257)),this[_0x335cc6(0x204)](_0x335cc6(0x23c)+_0x487e7f/0x3e8+_0x335cc6(0x207)),await this[_0x335cc6(0x25b)](_0x487e7f),_0x487e7f=Math[_0x335cc6(0x1f0)](_0x487e7f*1.5,0xea60);}}async[a0_0x2b779f(0x223)](){const _0x2fe3af=a0_0x2b779f;try{let _0x2c7599=(await this[_0x2fe3af(0x219)]('get_inbox',{'alias':this[_0x2fe3af(0x23d)],'limit':0xa}))?.['messages']||[];for(let _0xf5885c of _0x2c7599)await this[_0x2fe3af(0x219)]('ack_inbox',{'alias':this[_0x2fe3af(0x23d)],'message_id':_0xf5885c['id']}),this['log']('←\x20'+_0xf5885c[_0x2fe3af(0x220)]+':\x20'+_0xf5885c[_0x2fe3af(0x23a)]['slice'](0x0,0x3c)),this[_0x2fe3af(0x22d)](_0x2fe3af(0x24d),_0xf5885c),this['emit'](_0x2fe3af(0x23b),_0xf5885c);}catch(_0x4a0df7){this[_0x2fe3af(0x204)](_0x2fe3af(0x1f3)+_0x4a0df7['message']);}}[a0_0x2b779f(0x25b)](_0x1f7c9a){return new Promise(_0x1f3dff=>setTimeout(_0x1f3dff,_0x1f7c9a));}}function a0_0x4ece(_0x3c6a4a,_0x43f008){_0x3c6a4a=_0x3c6a4a-0x1e2;const _0x47b182=a0_0x47b1();let _0x4ece34=_0x47b182[_0x3c6a4a];return _0x4ece34;}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x1006a0=a0_0x85dc;(function(_0x208670,_0x5dca58){const _0x25dcf2=a0_0x85dc,_0x2c43d7=_0x208670();while(!![]){try{const _0x1089f5=parseInt(_0x25dcf2(0xff))/0x1*(parseInt(_0x25dcf2(0x11d))/0x2)+parseInt(_0x25dcf2(0xae))/0x3+-parseInt(_0x25dcf2(0xf0))/0x4*(-parseInt(_0x25dcf2(0x9f))/0x5)+parseInt(_0x25dcf2(0xe1))/0x6*(-parseInt(_0x25dcf2(0xc6))/0x7)+parseInt(_0x25dcf2(0x106))/0x8*(-parseInt(_0x25dcf2(0xab))/0x9)+-parseInt(_0x25dcf2(0xb3))/0xa+-parseInt(_0x25dcf2(0xf1))/0xb*(-parseInt(_0x25dcf2(0xa9))/0xc);if(_0x1089f5===_0x5dca58)break;else _0x2c43d7['push'](_0x2c43d7['shift']());}catch(_0x4a24ba){_0x2c43d7['push'](_0x2c43d7['shift']());}}}(a0_0x4288,0xb5193));import{EventEmitter as a0_0x32e1ff}from'events';import{hostname as a0_0x47dd29}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xe9357d,_0x228e18)=>(_0xe9357d??_0x228e18)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x1006a0(0xc3)](0x0,0xf0);function a0_0x85dc(_0xe60acb,_0x21e998){_0xe60acb=_0xe60acb-0x9e;const _0x42880e=a0_0x4288();let _0x85dc20=_0x42880e[_0xe60acb];return _0x85dc20;}function N(_0x3ff431){const _0x40b239=a0_0x1006a0;return(_0x3ff431 instanceof Error?_0x3ff431[_0x40b239(0xf4)]:String(_0x3ff431??_0x40b239(0xa0)))[_0x40b239(0xc5)](K,_0x40b239(0x10f))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x37a72c,_0x574131=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0xfe5d8a=a0_0x1006a0;if(_0x574131)return JSON[_0xfe5d8a(0xa5)](_0x37a72c);let _0x77808f=L(_0x37a72c[_0xfe5d8a(0x9e)],_0xfe5d8a(0xfe)),_0x1466a6=L(_0x37a72c[_0xfe5d8a(0xfb)],_0xfe5d8a(0x117)),_0x343f62=_0x37a72c[_0xfe5d8a(0xd6)]?_0xfe5d8a(0xe0)+_0x37a72c[_0xfe5d8a(0xd6)]+':'+(_0x37a72c[_0xfe5d8a(0x118)]??''):'';return _0xfe5d8a(0xcd)+_0x37a72c[_0xfe5d8a(0xe9)]+'\x20from='+L(_0x37a72c[_0xfe5d8a(0x119)],_0xfe5d8a(0xf6))+_0xfe5d8a(0xda)+L(_0x37a72c['to_alias'],_0xfe5d8a(0xf6))+_0xfe5d8a(0x101)+_0x1466a6+'\x20parent_task_id='+_0x77808f+_0xfe5d8a(0xd2)+L(_0x37a72c[_0xfe5d8a(0xea)],_0xfe5d8a(0xf6))+_0xfe5d8a(0x102)+_0x37a72c[_0xfe5d8a(0xb7)]+_0xfe5d8a(0xaa)+_0x37a72c[_0xfe5d8a(0xb4)]+_0xfe5d8a(0xc1)+_0x37a72c['lifecycle_tracking']+_0x343f62;}function U(_0x11d352){const _0x21739a=a0_0x1006a0;return{'event':{'sending':_0x21739a(0xc0),'delivered':_0x21739a(0xdb),'failed':_0x21739a(0xa2),'acked':_0x21739a(0xcf),'started':'task.started','replied':_0x21739a(0x113),'expired':_0x21739a(0xba)}[_0x11d352[_0x21739a(0xe9)]],..._0x11d352};}function j(_0x4ca0fb){const _0x402c7d=a0_0x1006a0;let _0x143246=_0x4ca0fb?.[_0x402c7d(0xfb)]||_0x4ca0fb?.[_0x402c7d(0xe7)]||_0x4ca0fb?.['id'];if(_0x143246)return String(_0x143246);let _0x18df90=_0x4ca0fb?.[_0x402c7d(0xa3)]?.[0x0]?.[_0x402c7d(0x114)];if(typeof _0x18df90!==_0x402c7d(0x10a))return null;try{let _0x1e12c8=JSON[_0x402c7d(0xb8)](_0x18df90);return _0x1e12c8?.['task_id']||_0x1e12c8?.['message_id']||_0x1e12c8?.['id']||null;}catch{return null;}}function a0_0x4288(){const _0x477eb0=['url','send','\x20to=','task.send.delivered','token','decode','toAlias','not_tracked','\x20error=','8173500HqLLQC','type','connectSSE','broadcast','emit','/events/','message_id','send_rejected','status','network_id','agent','body','log','sleep','connected','4DDpqIf','11RzaueB','report_status','sending','message','signal','<unknown>','resumeId','Authorization','fromAlias','text/event-stream','task_id','task','get_all_status','<missing>','82UUJdoz','disconnected','\x20task_id=','\x20transport=','2.0','send_failed','sdk-','8rgCzZq','tools/call','SSE\x20error:\x20','normal','string','reconnectDelay','toTimeString','registered','connect','[REDACTED]','autoConnect','delivered','idle','task.replied','text','offline','min','<pending>','error_message','from_alias','AbortError','s...','getReader','30350CQEAHV','heartbeat\x20failed:\x20','CommHub\x20response\x20omitted\x20task_id','parent_task_id','5223995QBtlae','unknown\x20error','split','task.send.failed','content','abort','stringify','error','disconnect','alias','8005272BYfvKT','\x20duration_ms=','9840429utwAVF','sseAbort','send_message','3206211ImvCTo','SSE\x20reconnecting\x20in\x20','startsWith','reply','sdk','8275820FoMIzD','duration_ms','completed','send_task','transport','parse','catch','task.expired','missing_task_id','application/json','SSE\x20failed:\x20','parentTaskId','mcp_http','task.send.start','\x20lifecycle=','heartbeatInterval','slice','call','replace','7UqfuBk','Bearer\x20','failed','now','server','send_reply','SSE\x20connected','[commhub:task]\x20','processInbox','task.ack','networkId','lifecycleTracking','\x20network_id=','running','heartbeatTimer','messages','error_code','pop'];a0_0x4288=function(){return _0x477eb0;};return a0_0x4288();}async function X(_0x15ee16,_0x19cff7){const _0x353a44=a0_0x1006a0;let _0x1ccf94=_0x19cff7[_0x353a44(0xc9)]??Date[_0x353a44(0xc9)],_0x3334d9=_0x1ccf94(),_0x3648a0=(_0x2315d8,_0x4a8be2,_0xb9db98,_0x1537d0)=>{const _0x261302=_0x353a44;_0x19cff7['log'](O(U({'from_alias':_0x15ee16[_0x261302(0xf9)],'to_alias':_0x15ee16[_0x261302(0xde)],'task_id':_0x4a8be2,'parent_task_id':_0x15ee16['parentTaskId'],'network_id':_0x15ee16[_0x261302(0xd0)],'transport':_0x15ee16['transport'],'status':_0x2315d8,'duration_ms':_0x1ccf94()-_0x3334d9,'lifecycle_tracking':_0x15ee16[_0x261302(0xd1)],..._0xb9db98!==void 0x0?{'error_code':_0x1537d0||_0x261302(0x104),'error_message':N(_0xb9db98)}:{}})));};_0x3648a0(_0x353a44(0xf3),null);try{let _0x31d7b3=await _0x19cff7[_0x353a44(0xd9)](),_0x3b3d8f=j(_0x31d7b3);if(_0x3b3d8f)_0x3648a0(_0x353a44(0x111),_0x3b3d8f);else{if(_0x31d7b3?.['ok']===!0x1||_0x31d7b3?.[_0x353a44(0xa6)])_0x3648a0(_0x353a44(0xc8),_0x3b3d8f,_0x31d7b3?.[_0x353a44(0xa6)]||'CommHub\x20rejected\x20task',_0x353a44(0xe8));else _0x3648a0(_0x353a44(0xc8),null,_0x353a44(0x11f),_0x353a44(0xbb));}return _0x31d7b3;}catch(_0x51542c){throw _0x3648a0(_0x353a44(0xc8),null,_0x51542c,'send_failed'),_0x51542c;}}async function Y(_0x1ebf31,_0x33e7fb){const _0x591da7=a0_0x1006a0;return X({'fromAlias':_0x1ebf31['fromAlias'],'toAlias':_0x1ebf31[_0x591da7(0xa8)],'parentTaskId':_0x1ebf31[_0x591da7(0xbe)]||null,'networkId':_0x1ebf31[_0x591da7(0xd0)]||null,'transport':_0x591da7(0xbf),'lifecycleTracking':_0x591da7(0xdf)},_0x33e7fb);}class $ extends a0_0x32e1ff{[a0_0x1006a0(0xd8)];[a0_0x1006a0(0xa8)];['token'];['agent'];[a0_0x1006a0(0xf7)];[a0_0x1006a0(0xc2)];[a0_0x1006a0(0x10b)];[a0_0x1006a0(0xd4)];[a0_0x1006a0(0xac)];['running']=!0x1;constructor(_0x13e493){const _0x20a3de=a0_0x1006a0;super();if(this[_0x20a3de(0xd8)]=_0x13e493[_0x20a3de(0xd8)]['replace'](/\/$/,''),this[_0x20a3de(0xa8)]=_0x13e493[_0x20a3de(0xa8)],this['token']=_0x13e493[_0x20a3de(0xdc)],this[_0x20a3de(0xeb)]=_0x13e493[_0x20a3de(0xeb)]||_0x20a3de(0xb2),this['resumeId']=_0x20a3de(0x105)+_0x13e493[_0x20a3de(0xa8)]+'-'+Date[_0x20a3de(0xc9)]()['toString'](0x24),this[_0x20a3de(0xc2)]=_0x13e493[_0x20a3de(0xc2)]??0x2bf20,this[_0x20a3de(0x10b)]=_0x13e493[_0x20a3de(0x10b)]??0xbb8,_0x13e493[_0x20a3de(0x110)]!==!0x1)this['connect']();}[a0_0x1006a0(0xed)](_0x138aa1){const _0x17afee=a0_0x1006a0;console[_0x17afee(0xed)]('['+new Date()[_0x17afee(0x10c)]()[_0x17afee(0xc3)](0x0,0x8)+']\x20[commhub:'+this[_0x17afee(0xa8)]+']\x20'+_0x138aa1);}async['call'](_0x4b4725,_0xa6014f){const _0x132578=a0_0x1006a0;let _0x2616d4={'Content-Type':_0x132578(0xbc),'Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x2616d4[_0x132578(0xf8)]=_0x132578(0xc7)+this['token'];let _0x40035e=await(await fetch(this['url']+'/mcp',{'method':'POST','headers':_0x2616d4,'body':JSON[_0x132578(0xa5)]({'jsonrpc':_0x132578(0x103),'id':Date['now'](),'method':_0x132578(0x107),'params':{'name':_0x4b4725,'arguments':_0xa6014f}})}))[_0x132578(0x114)](),_0x1519e0=_0x40035e['match'](/data: (.+)/),_0x303d1e=_0x1519e0?JSON[_0x132578(0xb8)](_0x1519e0[0x1]):JSON[_0x132578(0xb8)](_0x40035e),_0x9c78e9=_0x303d1e?.['result']?.[_0x132578(0xa3)]?.[0x0]?.['text'];return _0x9c78e9?JSON[_0x132578(0xb8)](_0x9c78e9):_0x303d1e;}async[a0_0x1006a0(0x10e)](){const _0x4bf6f5=a0_0x1006a0;if(this['running'])return;this[_0x4bf6f5(0xd3)]=!0x0,await this['status'](_0x4bf6f5(0x112)),this[_0x4bf6f5(0xed)](_0x4bf6f5(0x10d)),this[_0x4bf6f5(0xd4)]=setInterval(()=>{const _0x536c99=_0x4bf6f5;this[_0x536c99(0xe9)](_0x536c99(0x112))[_0x536c99(0xb9)](_0x58bf0f=>this[_0x536c99(0xed)](_0x536c99(0x11e)+_0x58bf0f[_0x536c99(0xf4)]));},this[_0x4bf6f5(0xc2)]),this[_0x4bf6f5(0xe3)]();}async[a0_0x1006a0(0xa7)](){const _0x51ffce=a0_0x1006a0;if(this[_0x51ffce(0xd3)]=!0x1,this['sseAbort']?.[_0x51ffce(0xa4)](),this[_0x51ffce(0xd4)])clearInterval(this[_0x51ffce(0xd4)]);await this['status'](_0x51ffce(0x115))[_0x51ffce(0xb9)](()=>{}),this[_0x51ffce(0xed)](_0x51ffce(0x100));}async[a0_0x1006a0(0xd9)](_0x491c27,_0x257739,_0x193cc9=a0_0x1006a0(0x109)){const _0x2581f7=a0_0x1006a0;return Y({'alias':_0x491c27,'fromAlias':this['alias']},{'log':_0x609c42=>console[_0x2581f7(0xed)](_0x609c42),'send':()=>this[_0x2581f7(0xc4)](_0x2581f7(0xb6),{'alias':_0x491c27,'task':_0x257739,'priority':_0x193cc9,'from_session':this[_0x2581f7(0xa8)]})});}async[a0_0x1006a0(0xf4)](_0x1b71e8,_0x3ffc4b){const _0x47c960=a0_0x1006a0;return this[_0x47c960(0xc4)](_0x47c960(0xad),{'alias':_0x1b71e8,'message':_0x3ffc4b,'from_session':this['alias']});}async[a0_0x1006a0(0xb1)](_0x5630c0,_0x30e6ff,_0x1d8051=a0_0x1006a0(0xb5)){const _0x32d5bd=a0_0x1006a0;return this[_0x32d5bd(0xc4)](_0x32d5bd(0xcb),{'in_reply_to':_0x5630c0,'text':_0x30e6ff,'status':_0x1d8051});}async[a0_0x1006a0(0xe9)](_0x5d3b91,_0x4b7a92){const _0x25f374=a0_0x1006a0;return this[_0x25f374(0xc4)](_0x25f374(0xf2),{'resume_id':this[_0x25f374(0xf7)],'alias':this[_0x25f374(0xa8)],'status':_0x5d3b91,'server':a0_0x47dd29(),'hostname':a0_0x47dd29(),'agent':this[_0x25f374(0xeb)],'project_dir':process['cwd'](),..._0x4b7a92});}async['getAllStatus'](){const _0x2bba5e=a0_0x1006a0;return this[_0x2bba5e(0xc4)](_0x2bba5e(0xfd),{});}async['broadcast'](_0x211678,_0x180416){const _0x15fa43=a0_0x1006a0;return this[_0x15fa43(0xc4)](_0x15fa43(0xe4),{'message':_0x211678,'filter_server':_0x180416?.[_0x15fa43(0xca)],'filter_status':_0x180416?.[_0x15fa43(0xe9)]});}async['connectSSE'](){const _0x22cdad=a0_0x1006a0;let _0x14cbb7=encodeURIComponent(this['alias']),_0x1ce789=this[_0x22cdad(0xd8)]+_0x22cdad(0xe6)+_0x14cbb7,_0x2a2ca4=this[_0x22cdad(0x10b)];while(this[_0x22cdad(0xd3)]){try{this['sseAbort']=new AbortController();let _0x2527b3={'Accept':_0x22cdad(0xfa)};if(this['token'])_0x2527b3[_0x22cdad(0xf8)]='Bearer\x20'+this[_0x22cdad(0xdc)];let _0x3ae4a1=await fetch(_0x1ce789,{'headers':_0x2527b3,'signal':this[_0x22cdad(0xac)][_0x22cdad(0xf5)]});if(!_0x3ae4a1['ok']||!_0x3ae4a1['body']){this[_0x22cdad(0xed)](_0x22cdad(0xbd)+_0x3ae4a1['status']),await this['sleep'](_0x2a2ca4),_0x2a2ca4=Math[_0x22cdad(0x116)](_0x2a2ca4*1.5,0xea60);continue;}_0x2a2ca4=this[_0x22cdad(0x10b)];let _0x5e1092=_0x3ae4a1[_0x22cdad(0xec)][_0x22cdad(0x11c)](),_0x480e4f=new TextDecoder(),_0x4ba6ad='';while(this[_0x22cdad(0xd3)]){let {done:_0x28d2ea,value:_0x5ba6fc}=await _0x5e1092['read']();if(_0x28d2ea)break;_0x4ba6ad+=_0x480e4f[_0x22cdad(0xdd)](_0x5ba6fc,{'stream':!0x0});let _0x477cc2=_0x4ba6ad[_0x22cdad(0xa1)]('\x0a');_0x4ba6ad=_0x477cc2[_0x22cdad(0xd7)]()||'';for(let _0x1cf87e of _0x477cc2){if(!_0x1cf87e[_0x22cdad(0xb0)]('data:\x20'))continue;try{let _0x23f6b1=JSON[_0x22cdad(0xb8)](_0x1cf87e[_0x22cdad(0xc3)](0x6));if(_0x23f6b1[_0x22cdad(0xe2)]===_0x22cdad(0xef)){this[_0x22cdad(0xed)](_0x22cdad(0xcc)),this[_0x22cdad(0xe5)](_0x22cdad(0xef));continue;}if(_0x23f6b1[_0x22cdad(0xe2)]==='new_task'||_0x23f6b1[_0x22cdad(0xe2)]==='new_message'||_0x23f6b1[_0x22cdad(0xe2)]===_0x22cdad(0xe4))await this[_0x22cdad(0xce)]();}catch{}}}}catch(_0x34a5e6){if(_0x34a5e6['name']===_0x22cdad(0x11a))break;this[_0x22cdad(0xe5)](_0x22cdad(0xa6),_0x34a5e6),this[_0x22cdad(0xed)](_0x22cdad(0x108)+_0x34a5e6[_0x22cdad(0xf4)]);}if(this[_0x22cdad(0xd3)])this[_0x22cdad(0xe5)](_0x22cdad(0x100)),this['log'](_0x22cdad(0xaf)+_0x2a2ca4/0x3e8+_0x22cdad(0x11b)),await this['sleep'](_0x2a2ca4),_0x2a2ca4=Math['min'](_0x2a2ca4*1.5,0xea60);}}async[a0_0x1006a0(0xce)](){const _0x1a24d5=a0_0x1006a0;try{let _0x153d4c=(await this[_0x1a24d5(0xc4)]('get_inbox',{'alias':this[_0x1a24d5(0xa8)],'limit':0xa}))?.[_0x1a24d5(0xd5)]||[];for(let _0x96e1a9 of _0x153d4c)await this[_0x1a24d5(0xc4)]('ack_inbox',{'alias':this['alias'],'message_id':_0x96e1a9['id']}),this[_0x1a24d5(0xed)]('←\x20'+_0x96e1a9['from_session']+':\x20'+_0x96e1a9[_0x1a24d5(0xa3)][_0x1a24d5(0xc3)](0x0,0x3c)),this[_0x1a24d5(0xe5)](_0x1a24d5(0xfc),_0x96e1a9),this[_0x1a24d5(0xe5)]('message',_0x96e1a9);}catch(_0x54bca5){this['log']('inbox\x20error:\x20'+_0x54bca5['message']);}}[a0_0x1006a0(0xee)](_0x86a539){return new Promise(_0x506156=>setTimeout(_0x506156,_0x86a539));}}var F=$;export{F as default,$ as CommHub};
|