@sleep2agi/agent-network 2.3.0-preview.169 → 2.3.0-preview.170
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_0x755606=a0_0xbac3;(function(_0x5e3f66,_0x5d89a5){const _0x4caa3d=a0_0xbac3,_0x3d253f=_0x5e3f66();while(!![]){try{const _0x84a9a8=-parseInt(_0x4caa3d(0xe6))/0x1*(-parseInt(_0x4caa3d(0xb1))/0x2)+parseInt(_0x4caa3d(0x7d))/0x3*(parseInt(_0x4caa3d(0xab))/0x4)+-parseInt(_0x4caa3d(0x7c))/0x5*(-parseInt(_0x4caa3d(0xdb))/0x6)+-parseInt(_0x4caa3d(0x81))/0x7+parseInt(_0x4caa3d(0x80))/0x8+parseInt(_0x4caa3d(0xeb))/0x9*(-parseInt(_0x4caa3d(0xc9))/0xa)+-parseInt(_0x4caa3d(0x88))/0xb*(parseInt(_0x4caa3d(0xb6))/0xc);if(_0x84a9a8===_0x5d89a5)break;else _0x3d253f['push'](_0x3d253f['shift']());}catch(_0x2278f4){_0x3d253f['push'](_0x3d253f['shift']());}}}(a0_0x4470,0x7d5e7));import{EventEmitter as a0_0xb7976c}from'events';import{hostname as a0_0xb344d0}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x1f5735,_0x4819c3)=>(_0x1f5735??_0x4819c3)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x755606(0xaa)](0x0,0xf0);function a0_0xbac3(_0x5e8812,_0xcb9295){_0x5e8812=_0x5e8812-0x76;const _0x447072=a0_0x4470();let _0xbac3d4=_0x447072[_0x5e8812];return _0xbac3d4;}function N(_0x2c5270){const _0x187ccd=a0_0x755606;return(_0x2c5270 instanceof Error?_0x2c5270[_0x187ccd(0xd4)]:String(_0x2c5270??_0x187ccd(0x9a)))[_0x187ccd(0xa7)](K,'[REDACTED]')[_0x187ccd(0xa7)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x187ccd(0xaa)](0x0,0xf0);}function O(_0x4bb00d,_0x14e2d8=process.env.ANET_TASK_TRACE_FORMAT===a0_0x755606(0xd2)){const _0x93ad04=a0_0x755606;if(_0x14e2d8)return JSON['stringify'](_0x4bb00d);let _0x434f1a=L(_0x4bb00d['parent_task_id'],_0x93ad04(0xe0)),_0x1cf688=L(_0x4bb00d[_0x93ad04(0xf2)],'<pending>'),_0x2bdbd4=_0x4bb00d['error_code']?_0x93ad04(0xd8)+_0x4bb00d[_0x93ad04(0x77)]+':'+(_0x4bb00d['error_message']??''):'';return _0x93ad04(0x97)+_0x4bb00d['status']+'\x20from='+L(_0x4bb00d[_0x93ad04(0xc4)],'<unknown>')+_0x93ad04(0x91)+L(_0x4bb00d[_0x93ad04(0x8d)],_0x93ad04(0xa4))+'\x20task_id='+_0x1cf688+_0x93ad04(0x87)+_0x434f1a+'\x20network_id='+L(_0x4bb00d[_0x93ad04(0xbd)],'<unknown>')+_0x93ad04(0xb7)+_0x4bb00d[_0x93ad04(0x7b)]+_0x93ad04(0xad)+_0x4bb00d[_0x93ad04(0x8c)]+_0x93ad04(0xa1)+_0x4bb00d[_0x93ad04(0xd7)]+_0x2bdbd4;}function U(_0x4acafb){const _0x5ef7b9=a0_0x755606;return{'event':{'sending':'task.send.start','delivered':'task.send.delivered','failed':_0x5ef7b9(0xf0),'acked':_0x5ef7b9(0x94),'started':'task.started','replied':_0x5ef7b9(0xa5),'expired':_0x5ef7b9(0xe9)}[_0x4acafb[_0x5ef7b9(0xa2)]],..._0x4acafb};}function j(_0x2bf1d0){const _0x39e68c=a0_0x755606;let _0x27f30f=_0x2bf1d0?.[_0x39e68c(0xf2)]||_0x2bf1d0?.[_0x39e68c(0x9c)]||_0x2bf1d0?.['id'];if(_0x27f30f)return String(_0x27f30f);let _0xc3a2ec=_0x2bf1d0?.[_0x39e68c(0x99)]?.[0x0]?.[_0x39e68c(0xd0)];if(typeof _0xc3a2ec!==_0x39e68c(0xb2))return null;try{let _0xe80625=JSON['parse'](_0xc3a2ec);return _0xe80625?.['task_id']||_0xe80625?.['message_id']||_0xe80625?.['id']||null;}catch{return null;}}function a0_0x4470(){const _0xa4bcfd=['Bearer\x20','task.send.failed','parentTaskId','task_id','new_message','heartbeatTimer','error_code','SSE\x20reconnecting\x20in\x20','reconnectDelay','registered','transport','2033155kUfbiO','57lhIKzP','getReader','Authorization','8102824ynGJVm','2867445HNXaRa','disconnect','log','startsWith','networkId','2.0','\x20parent_task_id=','517zRBKbM','disconnected','abort','send_message','duration_ms','to_alias','sdk','sseAbort','toTimeString','\x20to=','body','idle','task.ack','reply','offline','[commhub:task]\x20',']\x20[commhub:','content','unknown\x20error','send_task','message_id','getAllStatus','/events/','toAlias','error','\x20lifecycle=','status','delivered','<unknown>','task.replied','server','replace','data:\x20','autoConnect','slice','194284llOjdO','min','\x20duration_ms=','send_rejected','sending','connected','84742wVLXZv','string','report_status','catch','match','359616bRFrjg','\x20transport=','messages','pop','emit','text/event-stream','heartbeatInterval','network_id','processInbox','url','agent','get_all_status','parse','application/json,\x20text/event-stream','from_alias','sdk-','mcp_http','fromAlias','send_failed','5680ryKMmR','failed','SSE\x20connected','decode','type','connectSSE','name','text','lifecycleTracking','json','alias','message','token','signal','lifecycle_tracking','\x20error=','POST','split','6biPlsa','missing_task_id','sleep','broadcast','call','<missing>','send','running','from_session','/mcp','SSE\x20failed:\x20','7nNzQEq','resumeId','now','task.expired','tools/call','4869IUwqkG','AbortError','CommHub\x20response\x20omitted\x20task_id','completed'];a0_0x4470=function(){return _0xa4bcfd;};return a0_0x4470();}async function X(_0x3dfe22,_0xbff9ea){const _0x1d2ff8=a0_0x755606;let _0x146cd8=_0xbff9ea[_0x1d2ff8(0xe8)]??Date[_0x1d2ff8(0xe8)],_0x1c26c3=_0x146cd8(),_0x1d8d99=(_0x3e0055,_0x131f4e,_0x18f1f7,_0x35ab02)=>{const _0x2fa984=_0x1d2ff8;_0xbff9ea[_0x2fa984(0x83)](O(U({'from_alias':_0x3dfe22['fromAlias'],'to_alias':_0x3dfe22[_0x2fa984(0x9f)],'task_id':_0x131f4e,'parent_task_id':_0x3dfe22[_0x2fa984(0xf1)],'network_id':_0x3dfe22[_0x2fa984(0x85)],'transport':_0x3dfe22[_0x2fa984(0x7b)],'status':_0x3e0055,'duration_ms':_0x146cd8()-_0x1c26c3,'lifecycle_tracking':_0x3dfe22[_0x2fa984(0xd1)],..._0x18f1f7!==void 0x0?{'error_code':_0x35ab02||_0x2fa984(0xc8),'error_message':N(_0x18f1f7)}:{}})));};_0x1d8d99(_0x1d2ff8(0xaf),null);try{let _0x199e83=await _0xbff9ea['send'](),_0x132757=j(_0x199e83);if(_0x132757)_0x1d8d99(_0x1d2ff8(0xa3),_0x132757);else{if(_0x199e83?.['ok']===!0x1||_0x199e83?.[_0x1d2ff8(0xa0)])_0x1d8d99(_0x1d2ff8(0xca),_0x132757,_0x199e83?.[_0x1d2ff8(0xa0)]||'CommHub\x20rejected\x20task',_0x1d2ff8(0xae));else _0x1d8d99(_0x1d2ff8(0xca),null,_0x1d2ff8(0xed),_0x1d2ff8(0xdc));}return _0x199e83;}catch(_0x582074){throw _0x1d8d99(_0x1d2ff8(0xca),null,_0x582074,_0x1d2ff8(0xc8)),_0x582074;}}async function Y(_0x8622f4,_0x8a7da9){const _0x80171=a0_0x755606;return X({'fromAlias':_0x8622f4[_0x80171(0xc7)],'toAlias':_0x8622f4[_0x80171(0xd3)],'parentTaskId':_0x8622f4[_0x80171(0xf1)]||null,'networkId':_0x8622f4[_0x80171(0x85)]||null,'transport':_0x80171(0xc6),'lifecycleTracking':'not_tracked'},_0x8a7da9);}class $ extends a0_0xb7976c{['url'];[a0_0x755606(0xd3)];['token'];[a0_0x755606(0xc0)];[a0_0x755606(0xe7)];[a0_0x755606(0xbc)];[a0_0x755606(0x79)];['heartbeatTimer'];[a0_0x755606(0x8f)];[a0_0x755606(0xe2)]=!0x1;constructor(_0x4f875a){const _0x39f35b=a0_0x755606;super();if(this[_0x39f35b(0xbf)]=_0x4f875a[_0x39f35b(0xbf)][_0x39f35b(0xa7)](/\/$/,''),this[_0x39f35b(0xd3)]=_0x4f875a[_0x39f35b(0xd3)],this['token']=_0x4f875a['token'],this[_0x39f35b(0xc0)]=_0x4f875a[_0x39f35b(0xc0)]||_0x39f35b(0x8e),this[_0x39f35b(0xe7)]=_0x39f35b(0xc5)+_0x4f875a['alias']+'-'+Date[_0x39f35b(0xe8)]()['toString'](0x24),this[_0x39f35b(0xbc)]=_0x4f875a[_0x39f35b(0xbc)]??0x2bf20,this['reconnectDelay']=_0x4f875a[_0x39f35b(0x79)]??0xbb8,_0x4f875a[_0x39f35b(0xa9)]!==!0x1)this['connect']();}[a0_0x755606(0x83)](_0x4ac7c1){const _0x3ec785=a0_0x755606;console[_0x3ec785(0x83)]('['+new Date()[_0x3ec785(0x90)]()['slice'](0x0,0x8)+_0x3ec785(0x98)+this['alias']+']\x20'+_0x4ac7c1);}async[a0_0x755606(0xdf)](_0x49f2b3,_0x38bf40){const _0x28ef2a=a0_0x755606;let _0x1b21f3={'Content-Type':'application/json','Accept':_0x28ef2a(0xc3)};if(this[_0x28ef2a(0xd5)])_0x1b21f3[_0x28ef2a(0x7f)]=_0x28ef2a(0xef)+this['token'];let _0x5e59f1=await(await fetch(this[_0x28ef2a(0xbf)]+_0x28ef2a(0xe4),{'method':_0x28ef2a(0xd9),'headers':_0x1b21f3,'body':JSON['stringify']({'jsonrpc':_0x28ef2a(0x86),'id':Date[_0x28ef2a(0xe8)](),'method':_0x28ef2a(0xea),'params':{'name':_0x49f2b3,'arguments':_0x38bf40}})}))[_0x28ef2a(0xd0)](),_0x3d2df1=_0x5e59f1[_0x28ef2a(0xb5)](/data: (.+)/),_0x419ba6=_0x3d2df1?JSON[_0x28ef2a(0xc2)](_0x3d2df1[0x1]):JSON[_0x28ef2a(0xc2)](_0x5e59f1),_0x1f71d6=_0x419ba6?.['result']?.['content']?.[0x0]?.[_0x28ef2a(0xd0)];return _0x1f71d6?JSON['parse'](_0x1f71d6):_0x419ba6;}async['connect'](){const _0x177550=a0_0x755606;if(this['running'])return;this[_0x177550(0xe2)]=!0x0,await this['status'](_0x177550(0x93)),this['log'](_0x177550(0x7a)),this['heartbeatTimer']=setInterval(()=>{const _0x57109c=_0x177550;this[_0x57109c(0xa2)](_0x57109c(0x93))['catch'](_0x1bbc82=>this['log']('heartbeat\x20failed:\x20'+_0x1bbc82['message']));},this[_0x177550(0xbc)]),this['connectSSE']();}async[a0_0x755606(0x82)](){const _0x5bb8d3=a0_0x755606;if(this['running']=!0x1,this[_0x5bb8d3(0x8f)]?.[_0x5bb8d3(0x8a)](),this[_0x5bb8d3(0x76)])clearInterval(this['heartbeatTimer']);await this[_0x5bb8d3(0xa2)](_0x5bb8d3(0x96))[_0x5bb8d3(0xb4)](()=>{}),this[_0x5bb8d3(0x83)](_0x5bb8d3(0x89));}async[a0_0x755606(0xe1)](_0x479e75,_0x9f6ba1,_0x3e5bcb='normal'){const _0x5a4007=a0_0x755606;return Y({'alias':_0x479e75,'fromAlias':this['alias']},{'log':_0x4e8799=>console['log'](_0x4e8799),'send':()=>this[_0x5a4007(0xdf)](_0x5a4007(0x9b),{'alias':_0x479e75,'task':_0x9f6ba1,'priority':_0x3e5bcb,'from_session':this[_0x5a4007(0xd3)]})});}async[a0_0x755606(0xd4)](_0x3ff6b1,_0x4a2afa){const _0x1a8286=a0_0x755606;return this[_0x1a8286(0xdf)](_0x1a8286(0x8b),{'alias':_0x3ff6b1,'message':_0x4a2afa,'from_session':this[_0x1a8286(0xd3)]});}async[a0_0x755606(0x95)](_0x285368,_0x355f61,_0x2b87e2=a0_0x755606(0xee)){const _0x262841=a0_0x755606;return this[_0x262841(0xdf)]('send_reply',{'in_reply_to':_0x285368,'text':_0x355f61,'status':_0x2b87e2});}async[a0_0x755606(0xa2)](_0x2fd81a,_0x23066c){const _0x46a6eb=a0_0x755606;return this['call'](_0x46a6eb(0xb3),{'resume_id':this[_0x46a6eb(0xe7)],'alias':this[_0x46a6eb(0xd3)],'status':_0x2fd81a,'server':a0_0xb344d0(),'hostname':a0_0xb344d0(),'agent':this[_0x46a6eb(0xc0)],'project_dir':process['cwd'](),..._0x23066c});}async[a0_0x755606(0x9d)](){const _0x436c7f=a0_0x755606;return this['call'](_0x436c7f(0xc1),{});}async[a0_0x755606(0xde)](_0xa47780,_0x39704c){const _0x1a3578=a0_0x755606;return this[_0x1a3578(0xdf)]('broadcast',{'message':_0xa47780,'filter_server':_0x39704c?.[_0x1a3578(0xa6)],'filter_status':_0x39704c?.[_0x1a3578(0xa2)]});}async[a0_0x755606(0xce)](){const _0x398687=a0_0x755606;let _0x339f75=encodeURIComponent(this[_0x398687(0xd3)]),_0x254e7a=this[_0x398687(0xbf)]+_0x398687(0x9e)+_0x339f75,_0x1c5bf6=this[_0x398687(0x79)];while(this['running']){try{this[_0x398687(0x8f)]=new AbortController();let _0x304e44={'Accept':_0x398687(0xbb)};if(this[_0x398687(0xd5)])_0x304e44[_0x398687(0x7f)]='Bearer\x20'+this['token'];let _0x22001a=await fetch(_0x254e7a,{'headers':_0x304e44,'signal':this[_0x398687(0x8f)][_0x398687(0xd6)]});if(!_0x22001a['ok']||!_0x22001a[_0x398687(0x92)]){this[_0x398687(0x83)](_0x398687(0xe5)+_0x22001a[_0x398687(0xa2)]),await this['sleep'](_0x1c5bf6),_0x1c5bf6=Math[_0x398687(0xac)](_0x1c5bf6*1.5,0xea60);continue;}_0x1c5bf6=this[_0x398687(0x79)];let _0x5e988f=_0x22001a[_0x398687(0x92)][_0x398687(0x7e)](),_0x4946a0=new TextDecoder(),_0x4afe18='';while(this[_0x398687(0xe2)]){let {done:_0x4007d6,value:_0x5038c4}=await _0x5e988f['read']();if(_0x4007d6)break;_0x4afe18+=_0x4946a0[_0x398687(0xcc)](_0x5038c4,{'stream':!0x0});let _0x39769e=_0x4afe18[_0x398687(0xda)]('\x0a');_0x4afe18=_0x39769e[_0x398687(0xb9)]()||'';for(let _0x30ce54 of _0x39769e){if(!_0x30ce54[_0x398687(0x84)](_0x398687(0xa8)))continue;try{let _0x5a2be8=JSON[_0x398687(0xc2)](_0x30ce54[_0x398687(0xaa)](0x6));if(_0x5a2be8[_0x398687(0xcd)]===_0x398687(0xb0)){this[_0x398687(0x83)](_0x398687(0xcb)),this[_0x398687(0xba)](_0x398687(0xb0));continue;}if(_0x5a2be8[_0x398687(0xcd)]==='new_task'||_0x5a2be8[_0x398687(0xcd)]===_0x398687(0xf3)||_0x5a2be8[_0x398687(0xcd)]===_0x398687(0xde))await this[_0x398687(0xbe)]();}catch{}}}}catch(_0x121621){if(_0x121621[_0x398687(0xcf)]===_0x398687(0xec))break;this['emit'](_0x398687(0xa0),_0x121621),this[_0x398687(0x83)]('SSE\x20error:\x20'+_0x121621['message']);}if(this[_0x398687(0xe2)])this[_0x398687(0xba)](_0x398687(0x89)),this['log'](_0x398687(0x78)+_0x1c5bf6/0x3e8+'s...'),await this[_0x398687(0xdd)](_0x1c5bf6),_0x1c5bf6=Math[_0x398687(0xac)](_0x1c5bf6*1.5,0xea60);}}async[a0_0x755606(0xbe)](){const _0x41316a=a0_0x755606;try{let _0x2c324f=(await this[_0x41316a(0xdf)]('get_inbox',{'alias':this[_0x41316a(0xd3)],'limit':0xa}))?.[_0x41316a(0xb8)]||[];for(let _0x3a75a4 of _0x2c324f)await this['call']('ack_inbox',{'alias':this[_0x41316a(0xd3)],'message_id':_0x3a75a4['id']}),this[_0x41316a(0x83)]('←\x20'+_0x3a75a4[_0x41316a(0xe3)]+':\x20'+_0x3a75a4['content'][_0x41316a(0xaa)](0x0,0x3c)),this[_0x41316a(0xba)]('task',_0x3a75a4),this[_0x41316a(0xba)](_0x41316a(0xd4),_0x3a75a4);}catch(_0x308f73){this[_0x41316a(0x83)]('inbox\x20error:\x20'+_0x308f73[_0x41316a(0xd4)]);}}['sleep'](_0x44d489){return new Promise(_0x5c3898=>setTimeout(_0x5c3898,_0x44d489));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x190d23=a0_0x5089;(function(_0x5eb96b,_0x5b6f30){const _0x4a734d=a0_0x5089,_0x55aa4b=_0x5eb96b();while(!![]){try{const _0x41de9c=parseInt(_0x4a734d(0xc3))/0x1*(-parseInt(_0x4a734d(0xd7))/0x2)+parseInt(_0x4a734d(0x11b))/0x3+-parseInt(_0x4a734d(0xf9))/0x4*(-parseInt(_0x4a734d(0xa6))/0x5)+parseInt(_0x4a734d(0xd8))/0x6+-parseInt(_0x4a734d(0xe7))/0x7+-parseInt(_0x4a734d(0x100))/0x8*(-parseInt(_0x4a734d(0xae))/0x9)+-parseInt(_0x4a734d(0xa5))/0xa;if(_0x41de9c===_0x5b6f30)break;else _0x55aa4b['push'](_0x55aa4b['shift']());}catch(_0x1512e8){_0x55aa4b['push'](_0x55aa4b['shift']());}}}(a0_0x2ce7,0xbf3b5));import{EventEmitter as a0_0x22c93e}from'events';import{hostname as a0_0x2251a6}from'os';function a0_0x5089(_0x485b3c,_0x8d9619){_0x485b3c=_0x485b3c-0xa5;const _0x2ce7b4=a0_0x2ce7();let _0x508934=_0x2ce7b4[_0x485b3c];return _0x508934;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x1f2ce1,_0x12fd2f)=>(_0x1f2ce1??_0x12fd2f)[a0_0x190d23(0xff)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x5e2ca5){const _0x5eefd8=a0_0x190d23;return(_0x5e2ca5 instanceof Error?_0x5e2ca5[_0x5eefd8(0xd5)]:String(_0x5e2ca5??'unknown\x20error'))['replace'](K,'[REDACTED]')[_0x5eefd8(0xff)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5eefd8(0x10b)](0x0,0xf0);}function O(_0x3c018a,_0x2b54d3=process.env.ANET_TASK_TRACE_FORMAT===a0_0x190d23(0xfc)){const _0x46414e=a0_0x190d23;if(_0x2b54d3)return JSON[_0x46414e(0xaa)](_0x3c018a);let _0x3a5d8f=L(_0x3c018a[_0x46414e(0xfe)],_0x46414e(0xbe)),_0x56e195=L(_0x3c018a[_0x46414e(0xc0)],'<pending>'),_0x26af21=_0x3c018a[_0x46414e(0xf4)]?_0x46414e(0x11c)+_0x3c018a[_0x46414e(0xf4)]+':'+(_0x3c018a['error_message']??''):'';return _0x46414e(0x112)+_0x3c018a[_0x46414e(0x103)]+'\x20from='+L(_0x3c018a[_0x46414e(0xc2)],_0x46414e(0x118))+_0x46414e(0x111)+L(_0x3c018a['to_alias'],_0x46414e(0x118))+_0x46414e(0xc8)+_0x56e195+_0x46414e(0xd9)+_0x3a5d8f+_0x46414e(0xd6)+L(_0x3c018a['network_id'],_0x46414e(0x118))+'\x20transport='+_0x3c018a['transport']+'\x20duration_ms='+_0x3c018a['duration_ms']+_0x46414e(0xab)+_0x3c018a['lifecycle_tracking']+_0x26af21;}function U(_0x1e1cc1){const _0x228a6e=a0_0x190d23;return{'event':{'sending':'task.send.start','delivered':_0x228a6e(0xcf),'failed':'task.send.failed','acked':_0x228a6e(0xf6),'started':_0x228a6e(0xe9),'replied':_0x228a6e(0xe2),'expired':'task.expired'}[_0x1e1cc1[_0x228a6e(0x103)]],..._0x1e1cc1};}function j(_0x1134be){const _0x183cf9=a0_0x190d23;let _0x337466=_0x1134be?.[_0x183cf9(0xc0)]||_0x1134be?.[_0x183cf9(0x101)]||_0x1134be?.['id'];if(_0x337466)return String(_0x337466);let _0x5b9703=_0x1134be?.[_0x183cf9(0xdc)]?.[0x0]?.[_0x183cf9(0xac)];if(typeof _0x5b9703!=='string')return null;try{let _0x534f89=JSON[_0x183cf9(0x117)](_0x5b9703);return _0x534f89?.['task_id']||_0x534f89?.['message_id']||_0x534f89?.['id']||null;}catch{return null;}}async function X(_0x3efc2b,_0xf5099d){const _0x1f3c8f=a0_0x190d23;let _0x41c745=_0xf5099d[_0x1f3c8f(0xf2)]??Date[_0x1f3c8f(0xf2)],_0x3f48f7=_0x41c745(),_0x207f0d=(_0x5ec358,_0x467caf,_0x1c41c7,_0xdaf70b)=>{const _0x11c1a5=_0x1f3c8f;_0xf5099d['log'](O(U({'from_alias':_0x3efc2b[_0x11c1a5(0x116)],'to_alias':_0x3efc2b['toAlias'],'task_id':_0x467caf,'parent_task_id':_0x3efc2b[_0x11c1a5(0x114)],'network_id':_0x3efc2b[_0x11c1a5(0xc4)],'transport':_0x3efc2b[_0x11c1a5(0xc6)],'status':_0x5ec358,'duration_ms':_0x41c745()-_0x3f48f7,'lifecycle_tracking':_0x3efc2b[_0x11c1a5(0xe1)],..._0x1c41c7!==void 0x0?{'error_code':_0xdaf70b||'send_failed','error_message':N(_0x1c41c7)}:{}})));};_0x207f0d(_0x1f3c8f(0xcd),null);try{let _0x2beba3=await _0xf5099d['send'](),_0x18f2fc=j(_0x2beba3);if(_0x18f2fc)_0x207f0d(_0x1f3c8f(0xd3),_0x18f2fc);else{if(_0x2beba3?.['ok']===!0x1||_0x2beba3?.[_0x1f3c8f(0xea)])_0x207f0d(_0x1f3c8f(0x102),_0x18f2fc,_0x2beba3?.['error']||_0x1f3c8f(0x10e),'send_rejected');else _0x207f0d(_0x1f3c8f(0x102),null,_0x1f3c8f(0xe0),_0x1f3c8f(0x106));}return _0x2beba3;}catch(_0x27831c){throw _0x207f0d(_0x1f3c8f(0x102),null,_0x27831c,'send_failed'),_0x27831c;}}async function Y(_0x232dd0,_0x2d1be5){const _0x4a3f5b=a0_0x190d23;return X({'fromAlias':_0x232dd0[_0x4a3f5b(0x116)],'toAlias':_0x232dd0[_0x4a3f5b(0x105)],'parentTaskId':_0x232dd0[_0x4a3f5b(0x114)]||null,'networkId':_0x232dd0[_0x4a3f5b(0xc4)]||null,'transport':_0x4a3f5b(0x10c),'lifecycleTracking':'not_tracked'},_0x2d1be5);}class $ extends a0_0x22c93e{[a0_0x190d23(0xd1)];[a0_0x190d23(0x105)];[a0_0x190d23(0xec)];[a0_0x190d23(0xb5)];[a0_0x190d23(0xf8)];[a0_0x190d23(0xed)];[a0_0x190d23(0xe5)];[a0_0x190d23(0x115)];[a0_0x190d23(0xfa)];[a0_0x190d23(0xfd)]=!0x1;constructor(_0x46f4f0){const _0x5cdd76=a0_0x190d23;super();if(this[_0x5cdd76(0xd1)]=_0x46f4f0[_0x5cdd76(0xd1)][_0x5cdd76(0xff)](/\/$/,''),this[_0x5cdd76(0x105)]=_0x46f4f0[_0x5cdd76(0x105)],this[_0x5cdd76(0xec)]=_0x46f4f0[_0x5cdd76(0xec)],this[_0x5cdd76(0xb5)]=_0x46f4f0[_0x5cdd76(0xb5)]||_0x5cdd76(0xca),this['resumeId']=_0x5cdd76(0xcc)+_0x46f4f0[_0x5cdd76(0x105)]+'-'+Date[_0x5cdd76(0xf2)]()[_0x5cdd76(0xb0)](0x24),this[_0x5cdd76(0xed)]=_0x46f4f0[_0x5cdd76(0xed)]??0x2bf20,this['reconnectDelay']=_0x46f4f0['reconnectDelay']??0xbb8,_0x46f4f0[_0x5cdd76(0xc9)]!==!0x1)this['connect']();}[a0_0x190d23(0x109)](_0x5575b1){const _0x136c14=a0_0x190d23;console['log']('['+new Date()[_0x136c14(0xda)]()[_0x136c14(0x10b)](0x0,0x8)+_0x136c14(0xb3)+this['alias']+']\x20'+_0x5575b1);}async[a0_0x190d23(0xe8)](_0x221b61,_0x504f30){const _0x38c63d=a0_0x190d23;let _0xabd4={'Content-Type':_0x38c63d(0xb4),'Accept':_0x38c63d(0xce)};if(this[_0x38c63d(0xec)])_0xabd4[_0x38c63d(0x11a)]=_0x38c63d(0xb1)+this['token'];let _0x360f90=await(await fetch(this['url']+'/mcp',{'method':_0x38c63d(0xdd),'headers':_0xabd4,'body':JSON[_0x38c63d(0xaa)]({'jsonrpc':_0x38c63d(0xc7),'id':Date[_0x38c63d(0xf2)](),'method':_0x38c63d(0x10f),'params':{'name':_0x221b61,'arguments':_0x504f30}})}))[_0x38c63d(0xac)](),_0x229e04=_0x360f90[_0x38c63d(0xbb)](/data: (.+)/),_0x17d94b=_0x229e04?JSON[_0x38c63d(0x117)](_0x229e04[0x1]):JSON[_0x38c63d(0x117)](_0x360f90),_0x5925ee=_0x17d94b?.[_0x38c63d(0xb6)]?.['content']?.[0x0]?.['text'];return _0x5925ee?JSON[_0x38c63d(0x117)](_0x5925ee):_0x17d94b;}async[a0_0x190d23(0x10a)](){const _0x4d4988=a0_0x190d23;if(this[_0x4d4988(0xfd)])return;this[_0x4d4988(0xfd)]=!0x0,await this[_0x4d4988(0x103)](_0x4d4988(0xee)),this[_0x4d4988(0x109)]('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x6e812e=_0x4d4988;this['status']('idle')[_0x6e812e(0xdb)](_0x53bf86=>this[_0x6e812e(0x109)](_0x6e812e(0xd0)+_0x53bf86[_0x6e812e(0xd5)]));},this['heartbeatInterval']),this['connectSSE']();}async[a0_0x190d23(0x108)](){const _0x149c69=a0_0x190d23;if(this[_0x149c69(0xfd)]=!0x1,this[_0x149c69(0xfa)]?.['abort'](),this[_0x149c69(0x115)])clearInterval(this[_0x149c69(0x115)]);await this[_0x149c69(0x103)]('offline')[_0x149c69(0xdb)](()=>{}),this[_0x149c69(0x109)](_0x149c69(0xe6));}async[a0_0x190d23(0xbf)](_0x25e5b6,_0xe06523,_0x520f04=a0_0x190d23(0xbd)){const _0x466a55=a0_0x190d23;return Y({'alias':_0x25e5b6,'fromAlias':this[_0x466a55(0x105)]},{'log':_0x52d2ad=>console['log'](_0x52d2ad),'send':()=>this[_0x466a55(0xe8)](_0x466a55(0xf7),{'alias':_0x25e5b6,'task':_0xe06523,'priority':_0x520f04,'from_session':this[_0x466a55(0x105)]})});}async[a0_0x190d23(0xd5)](_0x3a13b6,_0x474e36){const _0x5529ab=a0_0x190d23;return this[_0x5529ab(0xe8)](_0x5529ab(0xa9),{'alias':_0x3a13b6,'message':_0x474e36,'from_session':this['alias']});}async[a0_0x190d23(0xd2)](_0x4a26ee,_0x338238,_0x3a7f87=a0_0x190d23(0xaf)){const _0x51a1fb=a0_0x190d23;return this['call'](_0x51a1fb(0x110),{'in_reply_to':_0x4a26ee,'text':_0x338238,'status':_0x3a7f87});}async['status'](_0x57c38f,_0x5cb7cb){const _0x23fb68=a0_0x190d23;return this[_0x23fb68(0xe8)](_0x23fb68(0xb8),{'resume_id':this[_0x23fb68(0xf8)],'alias':this[_0x23fb68(0x105)],'status':_0x57c38f,'server':a0_0x2251a6(),'hostname':a0_0x2251a6(),'agent':this[_0x23fb68(0xb5)],'project_dir':process[_0x23fb68(0xef)](),..._0x5cb7cb});}async['getAllStatus'](){const _0x14d3f3=a0_0x190d23;return this[_0x14d3f3(0xe8)](_0x14d3f3(0xde),{});}async[a0_0x190d23(0xa8)](_0xb407eb,_0x3c9f74){const _0x488ea0=a0_0x190d23;return this[_0x488ea0(0xe8)](_0x488ea0(0xa8),{'message':_0xb407eb,'filter_server':_0x3c9f74?.[_0x488ea0(0xcb)],'filter_status':_0x3c9f74?.[_0x488ea0(0x103)]});}async['connectSSE'](){const _0x4402a2=a0_0x190d23;let _0x358997=encodeURIComponent(this['alias']),_0xcb9536=this[_0x4402a2(0xd1)]+_0x4402a2(0xe3)+_0x358997,_0x1664f1=this[_0x4402a2(0xe5)];while(this[_0x4402a2(0xfd)]){try{this['sseAbort']=new AbortController();let _0x148ccf={'Accept':_0x4402a2(0x119)};if(this[_0x4402a2(0xec)])_0x148ccf['Authorization']=_0x4402a2(0xb1)+this[_0x4402a2(0xec)];let _0x574f03=await fetch(_0xcb9536,{'headers':_0x148ccf,'signal':this[_0x4402a2(0xfa)][_0x4402a2(0x113)]});if(!_0x574f03['ok']||!_0x574f03[_0x4402a2(0xba)]){this[_0x4402a2(0x109)](_0x4402a2(0xf5)+_0x574f03['status']),await this[_0x4402a2(0x104)](_0x1664f1),_0x1664f1=Math['min'](_0x1664f1*1.5,0xea60);continue;}_0x1664f1=this[_0x4402a2(0xe5)];let _0x578a5c=_0x574f03[_0x4402a2(0xba)][_0x4402a2(0xd4)](),_0x5cea38=new TextDecoder(),_0x178404='';while(this['running']){let {done:_0x4aa91d,value:_0x4e1c73}=await _0x578a5c[_0x4402a2(0xc5)]();if(_0x4aa91d)break;_0x178404+=_0x5cea38[_0x4402a2(0xf0)](_0x4e1c73,{'stream':!0x0});let _0x1c8f74=_0x178404['split']('\x0a');_0x178404=_0x1c8f74[_0x4402a2(0xb2)]()||'';for(let _0x5e1a7f of _0x1c8f74){if(!_0x5e1a7f['startsWith'](_0x4402a2(0xb7)))continue;try{let _0x1dbf32=JSON['parse'](_0x5e1a7f['slice'](0x6));if(_0x1dbf32[_0x4402a2(0xa7)]==='connected'){this[_0x4402a2(0x109)](_0x4402a2(0x10d)),this[_0x4402a2(0xc1)](_0x4402a2(0xf1));continue;}if(_0x1dbf32['type']==='new_task'||_0x1dbf32[_0x4402a2(0xa7)]==='new_message'||_0x1dbf32[_0x4402a2(0xa7)]===_0x4402a2(0xa8))await this[_0x4402a2(0xb9)]();}catch{}}}}catch(_0x31938e){if(_0x31938e[_0x4402a2(0x107)]===_0x4402a2(0xbc))break;this[_0x4402a2(0xc1)](_0x4402a2(0xea),_0x31938e),this[_0x4402a2(0x109)](_0x4402a2(0xf3)+_0x31938e[_0x4402a2(0xd5)]);}if(this[_0x4402a2(0xfd)])this[_0x4402a2(0xc1)](_0x4402a2(0xe6)),this[_0x4402a2(0x109)](_0x4402a2(0xeb)+_0x1664f1/0x3e8+'s...'),await this[_0x4402a2(0x104)](_0x1664f1),_0x1664f1=Math[_0x4402a2(0xfb)](_0x1664f1*1.5,0xea60);}}async['processInbox'](){const _0x5f1434=a0_0x190d23;try{let _0x15e6ae=(await this[_0x5f1434(0xe8)]('get_inbox',{'alias':this[_0x5f1434(0x105)],'limit':0xa}))?.[_0x5f1434(0xdf)]||[];for(let _0x35eb5b of _0x15e6ae)await this[_0x5f1434(0xe8)]('ack_inbox',{'alias':this[_0x5f1434(0x105)],'message_id':_0x35eb5b['id']}),this[_0x5f1434(0x109)]('←\x20'+_0x35eb5b[_0x5f1434(0xe4)]+':\x20'+_0x35eb5b[_0x5f1434(0xdc)]['slice'](0x0,0x3c)),this[_0x5f1434(0xc1)](_0x5f1434(0xad),_0x35eb5b),this[_0x5f1434(0xc1)](_0x5f1434(0xd5),_0x35eb5b);}catch(_0x42f754){this[_0x5f1434(0x109)]('inbox\x20error:\x20'+_0x42f754[_0x5f1434(0xd5)]);}}['sleep'](_0x1b4ed1){return new Promise(_0x3936e3=>setTimeout(_0x3936e3,_0x1b4ed1));}}var F=$;function a0_0x2ce7(){const _0x4a2cdf=['POST','get_all_status','messages','CommHub\x20response\x20omitted\x20task_id','lifecycleTracking','task.replied','/events/','from_session','reconnectDelay','disconnected','2461179PLLtbX','call','task.started','error','SSE\x20reconnecting\x20in\x20','token','heartbeatInterval','idle','cwd','decode','connected','now','SSE\x20error:\x20','error_code','SSE\x20failed:\x20','task.ack','send_task','resumeId','95136CtXLiR','sseAbort','min','json','running','parent_task_id','replace','1864376ZqrPyK','message_id','failed','status','sleep','alias','missing_task_id','name','disconnect','log','connect','slice','mcp_http','SSE\x20connected','CommHub\x20rejected\x20task','tools/call','send_reply','\x20to=','[commhub:task]\x20','signal','parentTaskId','heartbeatTimer','fromAlias','parse','<unknown>','text/event-stream','Authorization','3857247LGXMJs','\x20error=','24174810mxeBNq','280RRNAoi','type','broadcast','send_message','stringify','\x20lifecycle=','text','task','54RHyePS','completed','toString','Bearer\x20','pop',']\x20[commhub:','application/json','agent','result','data:\x20','report_status','processInbox','body','match','AbortError','normal','<missing>','send','task_id','emit','from_alias','5pAJvXm','networkId','read','transport','2.0','\x20task_id=','autoConnect','sdk','server','sdk-','sending','application/json,\x20text/event-stream','task.send.delivered','heartbeat\x20failed:\x20','url','reply','delivered','getReader','message','\x20network_id=','378022jyyYDq','2888898NerLiC','\x20parent_task_id=','toTimeString','catch','content'];a0_0x2ce7=function(){return _0x4a2cdf;};return a0_0x2ce7();}export{F as default,$ as CommHub};
|