@sleep2agi/agent-network 2.3.0-preview.122 → 2.3.0-preview.123
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
|
-
function a0_0x5227(){const _0x310858=['SSE\x20error:\x20','emit','task.replied','<missing>','registered','\x20from=','read','tools/call','resumeId','status','message_id','data:\x20','1038880MLCytS','\x20error=','idle','text/event-stream','<pending>',']\x20[commhub:','getReader','3AUkyUc','<unknown>','\x20lifecycle=','running','replace','text','fromAlias','heartbeatInterval','614853vqqGVn','result','server','Authorization','now','stringify','getAllStatus','SSE\x20failed:\x20','6ZxYDGv','networkId','reply','missing_task_id','offline','processInbox','error','/mcp','body','from_alias','failed','disconnected','error_message','error_code','abort','application/json,\x20text/event-stream','Bearer\x20','get_all_status','signal','connectSSE','AbortError','match','string','disconnect','6403800WgUZFe','\x20transport=','sdk','mcp_http','SSE\x20connected','sending','2.0','sleep','to_alias','sdk-','task_id','completed','token','sseAbort','parent_task_id','task.send.start','decode','startsWith','task.send.failed','autoConnect','content','new_message','task.expired','name','\x20duration_ms=','48854MwtQrK','agent','parse','send_task','lifecycleTracking','network_id','min','normal','send_message','connected','send_failed','POST','inbox\x20error:\x20','messages','send','broadcast','catch','report_status','application/json','heartbeatTimer','\x20to=','task.ack','lifecycle_tracking','json','transport','task.started','message','CommHub\x20rejected\x20task','5JSvVjX','alias','new_task','s...','call','slice','type','847564nwFVwM','reconnectDelay','\x20task_id=','connect','log','224253MZERNw','send_reply','get_inbox','task','toTimeString','1848091DLjKjT','toString','CommHub\x20response\x20omitted\x20task_id','url','unknown\x20error'];a0_0x5227=function(){return _0x310858;};return a0_0x5227();}const a0_0x4804e2=a0_0x1ce7;(function(_0x6a0457,_0x595fff){const _0x49b3f6=a0_0x1ce7,_0x5d9575=_0x6a0457();while(!![]){try{const _0x32e053=parseInt(_0x49b3f6(0x244))/0x1*(parseInt(_0x49b3f6(0x1ff))/0x2)+-parseInt(_0x49b3f6(0x24c))/0x3+parseInt(_0x49b3f6(0x222))/0x4*(-parseInt(_0x49b3f6(0x21b))/0x5)+-parseInt(_0x49b3f6(0x1ce))/0x6*(parseInt(_0x49b3f6(0x22c))/0x7)+parseInt(_0x49b3f6(0x23d))/0x8+-parseInt(_0x49b3f6(0x227))/0x9+parseInt(_0x49b3f6(0x1e6))/0xa;if(_0x32e053===_0x595fff)break;else _0x5d9575['push'](_0x5d9575['shift']());}catch(_0xac4e86){_0x5d9575['push'](_0x5d9575['shift']());}}}(a0_0x5227,0x21a15));import{EventEmitter as a0_0x1acb55}from'events';import{hostname as a0_0x316264}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4aecdb,_0x5112f5)=>(_0x4aecdb??_0x5112f5)[a0_0x4804e2(0x248)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x4804e2(0x220)](0x0,0xf0);function N(_0x4eebf5){const _0x39d0d7=a0_0x4804e2;return(_0x4eebf5 instanceof Error?_0x4eebf5[_0x39d0d7(0x219)]:String(_0x4eebf5??_0x39d0d7(0x230)))[_0x39d0d7(0x248)](K,'[REDACTED]')[_0x39d0d7(0x248)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x39d0d7(0x220)](0x0,0xf0);}function a0_0x1ce7(_0x342318,_0x5045a6){_0x342318=_0x342318-0x1cd;const _0x522715=a0_0x5227();let _0x1ce739=_0x522715[_0x342318];return _0x1ce739;}function O(_0x53d3aa,_0x13938e=process.env.ANET_TASK_TRACE_FORMAT===a0_0x4804e2(0x216)){const _0x462df5=a0_0x4804e2;if(_0x13938e)return JSON['stringify'](_0x53d3aa);let _0x113968=L(_0x53d3aa[_0x462df5(0x1f4)],_0x462df5(0x234)),_0x3c646d=L(_0x53d3aa[_0x462df5(0x1f0)],_0x462df5(0x241)),_0x49f4cc=_0x53d3aa[_0x462df5(0x1db)]?_0x462df5(0x23e)+_0x53d3aa[_0x462df5(0x1db)]+':'+(_0x53d3aa[_0x462df5(0x1da)]??''):'';return'[commhub:task]\x20'+_0x53d3aa[_0x462df5(0x23a)]+_0x462df5(0x236)+L(_0x53d3aa[_0x462df5(0x1d7)],_0x462df5(0x245))+_0x462df5(0x213)+L(_0x53d3aa[_0x462df5(0x1ee)],_0x462df5(0x245))+_0x462df5(0x224)+_0x3c646d+'\x20parent_task_id='+_0x113968+'\x20network_id='+L(_0x53d3aa[_0x462df5(0x204)],_0x462df5(0x245))+_0x462df5(0x1e7)+_0x53d3aa[_0x462df5(0x217)]+_0x462df5(0x1fe)+_0x53d3aa['duration_ms']+_0x462df5(0x246)+_0x53d3aa[_0x462df5(0x215)]+_0x49f4cc;}function U(_0x11b68c){const _0x4ae7e1=a0_0x4804e2;return{'event':{'sending':_0x4ae7e1(0x1f5),'delivered':'task.send.delivered','failed':_0x4ae7e1(0x1f8),'acked':_0x4ae7e1(0x214),'started':_0x4ae7e1(0x218),'replied':_0x4ae7e1(0x233),'expired':_0x4ae7e1(0x1fc)}[_0x11b68c[_0x4ae7e1(0x23a)]],..._0x11b68c};}function j(_0x46c743){const _0x1c6643=a0_0x4804e2;let _0x2ab9eb=_0x46c743?.[_0x1c6643(0x1f0)]||_0x46c743?.[_0x1c6643(0x23b)]||_0x46c743?.['id'];if(_0x2ab9eb)return String(_0x2ab9eb);let _0x3bd00c=_0x46c743?.[_0x1c6643(0x1fa)]?.[0x0]?.[_0x1c6643(0x249)];if(typeof _0x3bd00c!==_0x1c6643(0x1e4))return null;try{let _0x5267d4=JSON[_0x1c6643(0x201)](_0x3bd00c);return _0x5267d4?.[_0x1c6643(0x1f0)]||_0x5267d4?.[_0x1c6643(0x23b)]||_0x5267d4?.['id']||null;}catch{return null;}}async function X(_0x15fca8,_0x5c40d9){const _0x428433=a0_0x4804e2;let _0x95530d=_0x5c40d9[_0x428433(0x250)]??Date['now'],_0x1c39c2=_0x95530d(),_0x2e9fcb=(_0x577bc2,_0x832a8f,_0x415d26,_0xe174df)=>{const _0x34ccf2=_0x428433;_0x5c40d9[_0x34ccf2(0x226)](O(U({'from_alias':_0x15fca8['fromAlias'],'to_alias':_0x15fca8['toAlias'],'task_id':_0x832a8f,'parent_task_id':_0x15fca8['parentTaskId'],'network_id':_0x15fca8[_0x34ccf2(0x1cf)],'transport':_0x15fca8[_0x34ccf2(0x217)],'status':_0x577bc2,'duration_ms':_0x95530d()-_0x1c39c2,'lifecycle_tracking':_0x15fca8[_0x34ccf2(0x203)],..._0x415d26!==void 0x0?{'error_code':_0xe174df||_0x34ccf2(0x209),'error_message':N(_0x415d26)}:{}})));};_0x2e9fcb(_0x428433(0x1eb),null);try{let _0x2c8722=await _0x5c40d9[_0x428433(0x20d)](),_0x4858b0=j(_0x2c8722);if(_0x4858b0)_0x2e9fcb('delivered',_0x4858b0);else{if(_0x2c8722?.['ok']===!0x1||_0x2c8722?.['error'])_0x2e9fcb('failed',_0x4858b0,_0x2c8722?.[_0x428433(0x1d4)]||_0x428433(0x21a),'send_rejected');else _0x2e9fcb(_0x428433(0x1d8),null,_0x428433(0x22e),_0x428433(0x1d1));}return _0x2c8722;}catch(_0x4dd49a){throw _0x2e9fcb(_0x428433(0x1d8),null,_0x4dd49a,'send_failed'),_0x4dd49a;}}async function Y(_0x4d126a,_0x4034af){const _0x2f21a8=a0_0x4804e2;return X({'fromAlias':_0x4d126a[_0x2f21a8(0x24a)],'toAlias':_0x4d126a[_0x2f21a8(0x21c)],'parentTaskId':_0x4d126a['parentTaskId']||null,'networkId':_0x4d126a[_0x2f21a8(0x1cf)]||null,'transport':_0x2f21a8(0x1e9),'lifecycleTracking':'not_tracked'},_0x4034af);}class $ extends a0_0x1acb55{[a0_0x4804e2(0x22f)];['alias'];[a0_0x4804e2(0x1f2)];[a0_0x4804e2(0x200)];[a0_0x4804e2(0x239)];[a0_0x4804e2(0x24b)];[a0_0x4804e2(0x223)];['heartbeatTimer'];['sseAbort'];[a0_0x4804e2(0x247)]=!0x1;constructor(_0x51b296){const _0x1554f9=a0_0x4804e2;super();if(this[_0x1554f9(0x22f)]=_0x51b296[_0x1554f9(0x22f)][_0x1554f9(0x248)](/\/$/,''),this['alias']=_0x51b296[_0x1554f9(0x21c)],this[_0x1554f9(0x1f2)]=_0x51b296[_0x1554f9(0x1f2)],this[_0x1554f9(0x200)]=_0x51b296[_0x1554f9(0x200)]||_0x1554f9(0x1e8),this[_0x1554f9(0x239)]=_0x1554f9(0x1ef)+_0x51b296['alias']+'-'+Date[_0x1554f9(0x250)]()[_0x1554f9(0x22d)](0x24),this[_0x1554f9(0x24b)]=_0x51b296[_0x1554f9(0x24b)]??0x2bf20,this['reconnectDelay']=_0x51b296['reconnectDelay']??0xbb8,_0x51b296[_0x1554f9(0x1f9)]!==!0x1)this['connect']();}[a0_0x4804e2(0x226)](_0x1bcf99){const _0x1f6f32=a0_0x4804e2;console[_0x1f6f32(0x226)]('['+new Date()[_0x1f6f32(0x22b)]()[_0x1f6f32(0x220)](0x0,0x8)+_0x1f6f32(0x242)+this[_0x1f6f32(0x21c)]+']\x20'+_0x1bcf99);}async[a0_0x4804e2(0x21f)](_0x323d9f,_0x2a4bd6){const _0x509173=a0_0x4804e2;let _0xd6dfb={'Content-Type':_0x509173(0x211),'Accept':_0x509173(0x1dd)};if(this[_0x509173(0x1f2)])_0xd6dfb[_0x509173(0x24f)]='Bearer\x20'+this['token'];let _0x41b800=await(await fetch(this[_0x509173(0x22f)]+_0x509173(0x1d5),{'method':_0x509173(0x20a),'headers':_0xd6dfb,'body':JSON[_0x509173(0x251)]({'jsonrpc':_0x509173(0x1ec),'id':Date[_0x509173(0x250)](),'method':_0x509173(0x238),'params':{'name':_0x323d9f,'arguments':_0x2a4bd6}})}))[_0x509173(0x249)](),_0x146e22=_0x41b800[_0x509173(0x1e3)](/data: (.+)/),_0x3aac51=_0x146e22?JSON['parse'](_0x146e22[0x1]):JSON[_0x509173(0x201)](_0x41b800),_0x571303=_0x3aac51?.[_0x509173(0x24d)]?.[_0x509173(0x1fa)]?.[0x0]?.['text'];return _0x571303?JSON[_0x509173(0x201)](_0x571303):_0x3aac51;}async[a0_0x4804e2(0x225)](){const _0x48a510=a0_0x4804e2;if(this[_0x48a510(0x247)])return;this[_0x48a510(0x247)]=!0x0,await this[_0x48a510(0x23a)]('idle'),this[_0x48a510(0x226)](_0x48a510(0x235)),this[_0x48a510(0x212)]=setInterval(()=>{const _0x3c2620=_0x48a510;this[_0x3c2620(0x23a)](_0x3c2620(0x23f))[_0x3c2620(0x20f)](_0x47f14d=>this[_0x3c2620(0x226)]('heartbeat\x20failed:\x20'+_0x47f14d[_0x3c2620(0x219)]));},this[_0x48a510(0x24b)]),this[_0x48a510(0x1e1)]();}async[a0_0x4804e2(0x1e5)](){const _0x42d02b=a0_0x4804e2;if(this[_0x42d02b(0x247)]=!0x1,this['sseAbort']?.[_0x42d02b(0x1dc)](),this[_0x42d02b(0x212)])clearInterval(this[_0x42d02b(0x212)]);await this[_0x42d02b(0x23a)](_0x42d02b(0x1d2))[_0x42d02b(0x20f)](()=>{}),this[_0x42d02b(0x226)](_0x42d02b(0x1d9));}async[a0_0x4804e2(0x20d)](_0x3a6975,_0x2566ee,_0x3f9551=a0_0x4804e2(0x206)){const _0x3565a7=a0_0x4804e2;return Y({'alias':_0x3a6975,'fromAlias':this[_0x3565a7(0x21c)]},{'log':_0x14ff34=>console['log'](_0x14ff34),'send':()=>this['call'](_0x3565a7(0x202),{'alias':_0x3a6975,'task':_0x2566ee,'priority':_0x3f9551,'from_session':this['alias']})});}async[a0_0x4804e2(0x219)](_0x1fb621,_0x4829a6){const _0x3d20c2=a0_0x4804e2;return this[_0x3d20c2(0x21f)](_0x3d20c2(0x207),{'alias':_0x1fb621,'message':_0x4829a6,'from_session':this[_0x3d20c2(0x21c)]});}async[a0_0x4804e2(0x1d0)](_0x3c0a79,_0x1997e0,_0x331667=a0_0x4804e2(0x1f1)){const _0x9d0dd7=a0_0x4804e2;return this[_0x9d0dd7(0x21f)](_0x9d0dd7(0x228),{'in_reply_to':_0x3c0a79,'text':_0x1997e0,'status':_0x331667});}async[a0_0x4804e2(0x23a)](_0x35c140,_0xad561f){const _0x449789=a0_0x4804e2;return this[_0x449789(0x21f)](_0x449789(0x210),{'resume_id':this['resumeId'],'alias':this['alias'],'status':_0x35c140,'server':a0_0x316264(),'hostname':a0_0x316264(),'agent':this['agent'],'project_dir':process['cwd'](),..._0xad561f});}async[a0_0x4804e2(0x252)](){const _0x2d083f=a0_0x4804e2;return this[_0x2d083f(0x21f)](_0x2d083f(0x1df),{});}async['broadcast'](_0x33f243,_0x5d6247){const _0x4ebf1f=a0_0x4804e2;return this[_0x4ebf1f(0x21f)](_0x4ebf1f(0x20e),{'message':_0x33f243,'filter_server':_0x5d6247?.[_0x4ebf1f(0x24e)],'filter_status':_0x5d6247?.['status']});}async[a0_0x4804e2(0x1e1)](){const _0x5311ec=a0_0x4804e2;let _0x4a5dbc=encodeURIComponent(this['alias']),_0x36d6ff=this['url']+'/events/'+_0x4a5dbc,_0x52b5b7=this[_0x5311ec(0x223)];while(this[_0x5311ec(0x247)]){try{this[_0x5311ec(0x1f3)]=new AbortController();let _0x2c5a83={'Accept':_0x5311ec(0x240)};if(this[_0x5311ec(0x1f2)])_0x2c5a83[_0x5311ec(0x24f)]=_0x5311ec(0x1de)+this[_0x5311ec(0x1f2)];let _0x5a1b7b=await fetch(_0x36d6ff,{'headers':_0x2c5a83,'signal':this[_0x5311ec(0x1f3)][_0x5311ec(0x1e0)]});if(!_0x5a1b7b['ok']||!_0x5a1b7b[_0x5311ec(0x1d6)]){this[_0x5311ec(0x226)](_0x5311ec(0x1cd)+_0x5a1b7b['status']),await this[_0x5311ec(0x1ed)](_0x52b5b7),_0x52b5b7=Math[_0x5311ec(0x205)](_0x52b5b7*1.5,0xea60);continue;}_0x52b5b7=this['reconnectDelay'];let _0x277eef=_0x5a1b7b['body'][_0x5311ec(0x243)](),_0x4eff18=new TextDecoder(),_0x2a44af='';while(this['running']){let {done:_0x1953b0,value:_0x5d9d59}=await _0x277eef[_0x5311ec(0x237)]();if(_0x1953b0)break;_0x2a44af+=_0x4eff18[_0x5311ec(0x1f6)](_0x5d9d59,{'stream':!0x0});let _0x3276fd=_0x2a44af['split']('\x0a');_0x2a44af=_0x3276fd['pop']()||'';for(let _0x49df2e of _0x3276fd){if(!_0x49df2e[_0x5311ec(0x1f7)](_0x5311ec(0x23c)))continue;try{let _0x481259=JSON[_0x5311ec(0x201)](_0x49df2e[_0x5311ec(0x220)](0x6));if(_0x481259[_0x5311ec(0x221)]===_0x5311ec(0x208)){this['log'](_0x5311ec(0x1ea)),this[_0x5311ec(0x232)](_0x5311ec(0x208));continue;}if(_0x481259[_0x5311ec(0x221)]===_0x5311ec(0x21d)||_0x481259[_0x5311ec(0x221)]===_0x5311ec(0x1fb)||_0x481259[_0x5311ec(0x221)]===_0x5311ec(0x20e))await this[_0x5311ec(0x1d3)]();}catch{}}}}catch(_0x323f01){if(_0x323f01[_0x5311ec(0x1fd)]===_0x5311ec(0x1e2))break;this[_0x5311ec(0x232)](_0x5311ec(0x1d4),_0x323f01),this[_0x5311ec(0x226)](_0x5311ec(0x231)+_0x323f01[_0x5311ec(0x219)]);}if(this['running'])this[_0x5311ec(0x232)](_0x5311ec(0x1d9)),this['log']('SSE\x20reconnecting\x20in\x20'+_0x52b5b7/0x3e8+_0x5311ec(0x21e)),await this[_0x5311ec(0x1ed)](_0x52b5b7),_0x52b5b7=Math[_0x5311ec(0x205)](_0x52b5b7*1.5,0xea60);}}async[a0_0x4804e2(0x1d3)](){const _0x3ee230=a0_0x4804e2;try{let _0x5c3c77=(await this[_0x3ee230(0x21f)](_0x3ee230(0x229),{'alias':this[_0x3ee230(0x21c)],'limit':0xa}))?.[_0x3ee230(0x20c)]||[];for(let _0x35a13a of _0x5c3c77)await this[_0x3ee230(0x21f)]('ack_inbox',{'alias':this[_0x3ee230(0x21c)],'message_id':_0x35a13a['id']}),this[_0x3ee230(0x226)]('←\x20'+_0x35a13a['from_session']+':\x20'+_0x35a13a[_0x3ee230(0x1fa)][_0x3ee230(0x220)](0x0,0x3c)),this[_0x3ee230(0x232)](_0x3ee230(0x22a),_0x35a13a),this[_0x3ee230(0x232)](_0x3ee230(0x219),_0x35a13a);}catch(_0x36a7cf){this[_0x3ee230(0x226)](_0x3ee230(0x20b)+_0x36a7cf['message']);}}[a0_0x4804e2(0x1ed)](_0x4e4f97){return new Promise(_0x50c3df=>setTimeout(_0x50c3df,_0x4e4f97));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x47b98e=a0_0x3421;(function(_0x2c41b7,_0x150036){const _0x1fad7d=a0_0x3421,_0x3f2fcc=_0x2c41b7();while(!![]){try{const _0x35aa90=-parseInt(_0x1fad7d(0x202))/0x1*(parseInt(_0x1fad7d(0x187))/0x2)+-parseInt(_0x1fad7d(0x1b2))/0x3+parseInt(_0x1fad7d(0x1b9))/0x4+parseInt(_0x1fad7d(0x1d7))/0x5*(-parseInt(_0x1fad7d(0x1dc))/0x6)+-parseInt(_0x1fad7d(0x1c6))/0x7*(-parseInt(_0x1fad7d(0x1a0))/0x8)+-parseInt(_0x1fad7d(0x193))/0x9*(parseInt(_0x1fad7d(0x1d4))/0xa)+parseInt(_0x1fad7d(0x203))/0xb;if(_0x35aa90===_0x150036)break;else _0x3f2fcc['push'](_0x3f2fcc['shift']());}catch(_0x53a201){_0x3f2fcc['push'](_0x3f2fcc['shift']());}}}(a0_0xbb26,0x5b0e8));import{EventEmitter as a0_0x1389fb}from'events';import{hostname as a0_0x15db84}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4dee4b,_0x49cc06)=>(_0x4dee4b??_0x49cc06)[a0_0x47b98e(0x186)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x3516ab){const _0x31f282=a0_0x47b98e;return(_0x3516ab instanceof Error?_0x3516ab[_0x31f282(0x1fa)]:String(_0x3516ab??_0x31f282(0x19d)))['replace'](K,_0x31f282(0x1cc))[_0x31f282(0x186)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x31f282(0x1b7)](0x0,0xf0);}function O(_0x5a1591,_0x2f6cd6=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x3fcf4a=a0_0x47b98e;if(_0x2f6cd6)return JSON[_0x3fcf4a(0x1de)](_0x5a1591);let _0x429fc5=L(_0x5a1591[_0x3fcf4a(0x1e6)],_0x3fcf4a(0x1f6)),_0x28b2bd=L(_0x5a1591[_0x3fcf4a(0x1bc)],_0x3fcf4a(0x201)),_0x5a4b49=_0x5a1591[_0x3fcf4a(0x1ad)]?_0x3fcf4a(0x1c5)+_0x5a1591[_0x3fcf4a(0x1ad)]+':'+(_0x5a1591[_0x3fcf4a(0x18e)]??''):'';return _0x3fcf4a(0x1fd)+_0x5a1591['status']+_0x3fcf4a(0x1ab)+L(_0x5a1591[_0x3fcf4a(0x1c3)],'<unknown>')+_0x3fcf4a(0x1c2)+L(_0x5a1591[_0x3fcf4a(0x192)],_0x3fcf4a(0x1ec))+_0x3fcf4a(0x1ff)+_0x28b2bd+_0x3fcf4a(0x1d1)+_0x429fc5+_0x3fcf4a(0x1b3)+L(_0x5a1591[_0x3fcf4a(0x1b5)],_0x3fcf4a(0x1ec))+_0x3fcf4a(0x18b)+_0x5a1591[_0x3fcf4a(0x1f0)]+'\x20duration_ms='+_0x5a1591['duration_ms']+_0x3fcf4a(0x19c)+_0x5a1591[_0x3fcf4a(0x1fc)]+_0x5a4b49;}function a0_0xbb26(){const _0x1ea477=['407973AIkmqc','\x20network_id=','AbortError','network_id','ack_inbox','slice','read','2607096LXWUgP','connected','server','task_id','autoConnect','text/event-stream','token','emit','tools/call','\x20to=','from_alias','call','\x20error=','7poevpF','min','task.started','match','resumeId','s...','[REDACTED]','parse','heartbeatInterval','SSE\x20failed:\x20','delivered','\x20parent_task_id=','getReader','name','3026710kwmGwW','report_status','sdk-','5RbhOxr','sleep','inbox\x20error:\x20','send_task','sending','4264098NRTPtm','text','stringify','agent','not_tracked','now','type','error','parentTaskId','get_inbox','parent_task_id','toTimeString','sseAbort','split','send','new_task','<unknown>','connect','2.0','CommHub\x20rejected\x20task','transport','heartbeatTimer','idle','connectSSE','data:\x20','fromAlias','<missing>','signal','/events/','get_all_status','message','Authorization','lifecycle_tracking','[commhub:task]\x20','SSE\x20error:\x20','\x20task_id=','send_failed','<pending>','1qOrRjK','17481882mYYenJ','log','heartbeat\x20failed:\x20','replace','1485538zwTCEk','task.send.failed','missing_task_id','registered','\x20transport=','CommHub\x20response\x20omitted\x20task_id','reply','error_message','normal','disconnect','disconnected','to_alias','9jYnDjA','cwd','SSE\x20connected','running','POST','send_rejected','alias','networkId','url','\x20lifecycle=','unknown\x20error','catch','broadcast','192368CsAVnr','task.ack','application/json,\x20text/event-stream','task.send.delivered','from_session','Bearer\x20','status','lifecycleTracking','reconnectDelay','toAlias','body','\x20from=','abort','error_code','send_message','content','task.expired','pop'];a0_0xbb26=function(){return _0x1ea477;};return a0_0xbb26();}function U(_0xb48fd5){const _0x1e5217=a0_0x47b98e;return{'event':{'sending':'task.send.start','delivered':_0x1e5217(0x1a3),'failed':_0x1e5217(0x188),'acked':_0x1e5217(0x1a1),'started':_0x1e5217(0x1c8),'replied':'task.replied','expired':_0x1e5217(0x1b0)}[_0xb48fd5[_0x1e5217(0x1a6)]],..._0xb48fd5};}function j(_0x1d47c8){const _0x3cc32c=a0_0x47b98e;let _0x1e222d=_0x1d47c8?.[_0x3cc32c(0x1bc)]||_0x1d47c8?.['message_id']||_0x1d47c8?.['id'];if(_0x1e222d)return String(_0x1e222d);let _0x56ccec=_0x1d47c8?.[_0x3cc32c(0x1af)]?.[0x0]?.[_0x3cc32c(0x1dd)];if(typeof _0x56ccec!=='string')return null;try{let _0x3b1954=JSON[_0x3cc32c(0x1cd)](_0x56ccec);return _0x3b1954?.[_0x3cc32c(0x1bc)]||_0x3b1954?.['message_id']||_0x3b1954?.['id']||null;}catch{return null;}}async function X(_0x255c5c,_0x43c52a){const _0x7a9854=a0_0x47b98e;let _0x212472=_0x43c52a[_0x7a9854(0x1e1)]??Date[_0x7a9854(0x1e1)],_0x4c9925=_0x212472(),_0x1f2f47=(_0x535f72,_0x8d88f8,_0x4ae0cc,_0x214eee)=>{const _0x43e640=_0x7a9854;_0x43c52a['log'](O(U({'from_alias':_0x255c5c[_0x43e640(0x1f5)],'to_alias':_0x255c5c[_0x43e640(0x1a9)],'task_id':_0x8d88f8,'parent_task_id':_0x255c5c[_0x43e640(0x1e4)],'network_id':_0x255c5c[_0x43e640(0x19a)],'transport':_0x255c5c[_0x43e640(0x1f0)],'status':_0x535f72,'duration_ms':_0x212472()-_0x4c9925,'lifecycle_tracking':_0x255c5c[_0x43e640(0x1a7)],..._0x4ae0cc!==void 0x0?{'error_code':_0x214eee||'send_failed','error_message':N(_0x4ae0cc)}:{}})));};_0x1f2f47(_0x7a9854(0x1db),null);try{let _0x22fd77=await _0x43c52a[_0x7a9854(0x1ea)](),_0x3faaf6=j(_0x22fd77);if(_0x3faaf6)_0x1f2f47(_0x7a9854(0x1d0),_0x3faaf6);else{if(_0x22fd77?.['ok']===!0x1||_0x22fd77?.[_0x7a9854(0x1e3)])_0x1f2f47('failed',_0x3faaf6,_0x22fd77?.['error']||_0x7a9854(0x1ef),_0x7a9854(0x198));else _0x1f2f47('failed',null,_0x7a9854(0x18c),_0x7a9854(0x189));}return _0x22fd77;}catch(_0x5930bb){throw _0x1f2f47('failed',null,_0x5930bb,_0x7a9854(0x200)),_0x5930bb;}}async function Y(_0xa2021,_0x4efd20){const _0x449f8b=a0_0x47b98e;return X({'fromAlias':_0xa2021['fromAlias'],'toAlias':_0xa2021[_0x449f8b(0x199)],'parentTaskId':_0xa2021[_0x449f8b(0x1e4)]||null,'networkId':_0xa2021['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x449f8b(0x1e0)},_0x4efd20);}class $ extends a0_0x1389fb{[a0_0x47b98e(0x19b)];[a0_0x47b98e(0x199)];[a0_0x47b98e(0x1bf)];[a0_0x47b98e(0x1df)];['resumeId'];['heartbeatInterval'];[a0_0x47b98e(0x1a8)];[a0_0x47b98e(0x1f1)];[a0_0x47b98e(0x1e8)];['running']=!0x1;constructor(_0x5d63f7){const _0x2d2765=a0_0x47b98e;super();if(this[_0x2d2765(0x19b)]=_0x5d63f7[_0x2d2765(0x19b)][_0x2d2765(0x186)](/\/$/,''),this[_0x2d2765(0x199)]=_0x5d63f7[_0x2d2765(0x199)],this[_0x2d2765(0x1bf)]=_0x5d63f7[_0x2d2765(0x1bf)],this[_0x2d2765(0x1df)]=_0x5d63f7[_0x2d2765(0x1df)]||'sdk',this[_0x2d2765(0x1ca)]=_0x2d2765(0x1d6)+_0x5d63f7[_0x2d2765(0x199)]+'-'+Date[_0x2d2765(0x1e1)]()['toString'](0x24),this[_0x2d2765(0x1ce)]=_0x5d63f7[_0x2d2765(0x1ce)]??0x2bf20,this['reconnectDelay']=_0x5d63f7[_0x2d2765(0x1a8)]??0xbb8,_0x5d63f7[_0x2d2765(0x1bd)]!==!0x1)this[_0x2d2765(0x1ed)]();}[a0_0x47b98e(0x204)](_0x3e8d85){const _0x18627d=a0_0x47b98e;console[_0x18627d(0x204)]('['+new Date()[_0x18627d(0x1e7)]()[_0x18627d(0x1b7)](0x0,0x8)+']\x20[commhub:'+this[_0x18627d(0x199)]+']\x20'+_0x3e8d85);}async[a0_0x47b98e(0x1c4)](_0x3a8de4,_0x516ad1){const _0x5360ff=a0_0x47b98e;let _0x2b2309={'Content-Type':'application/json','Accept':_0x5360ff(0x1a2)};if(this[_0x5360ff(0x1bf)])_0x2b2309[_0x5360ff(0x1fb)]=_0x5360ff(0x1a5)+this[_0x5360ff(0x1bf)];let _0x4d6135=await(await fetch(this[_0x5360ff(0x19b)]+'/mcp',{'method':_0x5360ff(0x197),'headers':_0x2b2309,'body':JSON[_0x5360ff(0x1de)]({'jsonrpc':_0x5360ff(0x1ee),'id':Date[_0x5360ff(0x1e1)](),'method':_0x5360ff(0x1c1),'params':{'name':_0x3a8de4,'arguments':_0x516ad1}})}))[_0x5360ff(0x1dd)](),_0x1fdf1e=_0x4d6135[_0x5360ff(0x1c9)](/data: (.+)/),_0x58b208=_0x1fdf1e?JSON[_0x5360ff(0x1cd)](_0x1fdf1e[0x1]):JSON[_0x5360ff(0x1cd)](_0x4d6135),_0x4e1a00=_0x58b208?.['result']?.['content']?.[0x0]?.['text'];return _0x4e1a00?JSON[_0x5360ff(0x1cd)](_0x4e1a00):_0x58b208;}async[a0_0x47b98e(0x1ed)](){const _0x2e5480=a0_0x47b98e;if(this['running'])return;this[_0x2e5480(0x196)]=!0x0,await this[_0x2e5480(0x1a6)](_0x2e5480(0x1f2)),this[_0x2e5480(0x204)](_0x2e5480(0x18a)),this[_0x2e5480(0x1f1)]=setInterval(()=>{const _0x2b3255=_0x2e5480;this['status']('idle')[_0x2b3255(0x19e)](_0x22f50d=>this[_0x2b3255(0x204)](_0x2b3255(0x185)+_0x22f50d[_0x2b3255(0x1fa)]));},this['heartbeatInterval']),this[_0x2e5480(0x1f3)]();}async[a0_0x47b98e(0x190)](){const _0x6d41d4=a0_0x47b98e;if(this[_0x6d41d4(0x196)]=!0x1,this[_0x6d41d4(0x1e8)]?.[_0x6d41d4(0x1ac)](),this[_0x6d41d4(0x1f1)])clearInterval(this[_0x6d41d4(0x1f1)]);await this[_0x6d41d4(0x1a6)]('offline')[_0x6d41d4(0x19e)](()=>{}),this[_0x6d41d4(0x204)](_0x6d41d4(0x191));}async[a0_0x47b98e(0x1ea)](_0x3038ef,_0x37221e,_0xdf7541=a0_0x47b98e(0x18f)){const _0x4054d3=a0_0x47b98e;return Y({'alias':_0x3038ef,'fromAlias':this[_0x4054d3(0x199)]},{'log':_0x200355=>console['log'](_0x200355),'send':()=>this[_0x4054d3(0x1c4)](_0x4054d3(0x1da),{'alias':_0x3038ef,'task':_0x37221e,'priority':_0xdf7541,'from_session':this[_0x4054d3(0x199)]})});}async[a0_0x47b98e(0x1fa)](_0x3c4fea,_0x22d508){const _0x29d86b=a0_0x47b98e;return this[_0x29d86b(0x1c4)](_0x29d86b(0x1ae),{'alias':_0x3c4fea,'message':_0x22d508,'from_session':this[_0x29d86b(0x199)]});}async[a0_0x47b98e(0x18d)](_0x185662,_0x22b7c5,_0x3f0161='completed'){return this['call']('send_reply',{'in_reply_to':_0x185662,'text':_0x22b7c5,'status':_0x3f0161});}async[a0_0x47b98e(0x1a6)](_0x37bc6e,_0xff9159){const _0x1456c8=a0_0x47b98e;return this[_0x1456c8(0x1c4)](_0x1456c8(0x1d5),{'resume_id':this[_0x1456c8(0x1ca)],'alias':this[_0x1456c8(0x199)],'status':_0x37bc6e,'server':a0_0x15db84(),'hostname':a0_0x15db84(),'agent':this['agent'],'project_dir':process[_0x1456c8(0x194)](),..._0xff9159});}async['getAllStatus'](){const _0x4516de=a0_0x47b98e;return this['call'](_0x4516de(0x1f9),{});}async['broadcast'](_0x48655b,_0x44213e){const _0x238c5d=a0_0x47b98e;return this['call']('broadcast',{'message':_0x48655b,'filter_server':_0x44213e?.[_0x238c5d(0x1bb)],'filter_status':_0x44213e?.[_0x238c5d(0x1a6)]});}async[a0_0x47b98e(0x1f3)](){const _0x24dade=a0_0x47b98e;let _0x5263ce=encodeURIComponent(this['alias']),_0x497b72=this[_0x24dade(0x19b)]+_0x24dade(0x1f8)+_0x5263ce,_0x49ebb1=this[_0x24dade(0x1a8)];while(this['running']){try{this[_0x24dade(0x1e8)]=new AbortController();let _0x22ae62={'Accept':_0x24dade(0x1be)};if(this[_0x24dade(0x1bf)])_0x22ae62[_0x24dade(0x1fb)]='Bearer\x20'+this[_0x24dade(0x1bf)];let _0x5500e3=await fetch(_0x497b72,{'headers':_0x22ae62,'signal':this[_0x24dade(0x1e8)][_0x24dade(0x1f7)]});if(!_0x5500e3['ok']||!_0x5500e3[_0x24dade(0x1aa)]){this[_0x24dade(0x204)](_0x24dade(0x1cf)+_0x5500e3[_0x24dade(0x1a6)]),await this[_0x24dade(0x1d8)](_0x49ebb1),_0x49ebb1=Math[_0x24dade(0x1c7)](_0x49ebb1*1.5,0xea60);continue;}_0x49ebb1=this['reconnectDelay'];let _0x5976b7=_0x5500e3[_0x24dade(0x1aa)][_0x24dade(0x1d2)](),_0x344710=new TextDecoder(),_0x5c4a0f='';while(this[_0x24dade(0x196)]){let {done:_0x3d8b0c,value:_0x45b840}=await _0x5976b7[_0x24dade(0x1b8)]();if(_0x3d8b0c)break;_0x5c4a0f+=_0x344710['decode'](_0x45b840,{'stream':!0x0});let _0x4da248=_0x5c4a0f[_0x24dade(0x1e9)]('\x0a');_0x5c4a0f=_0x4da248[_0x24dade(0x1b1)]()||'';for(let _0x5a3fb7 of _0x4da248){if(!_0x5a3fb7['startsWith'](_0x24dade(0x1f4)))continue;try{let _0x38e673=JSON[_0x24dade(0x1cd)](_0x5a3fb7['slice'](0x6));if(_0x38e673[_0x24dade(0x1e2)]===_0x24dade(0x1ba)){this['log'](_0x24dade(0x195)),this[_0x24dade(0x1c0)](_0x24dade(0x1ba));continue;}if(_0x38e673[_0x24dade(0x1e2)]===_0x24dade(0x1eb)||_0x38e673['type']==='new_message'||_0x38e673[_0x24dade(0x1e2)]===_0x24dade(0x19f))await this['processInbox']();}catch{}}}}catch(_0x39f36e){if(_0x39f36e[_0x24dade(0x1d3)]===_0x24dade(0x1b4))break;this[_0x24dade(0x1c0)](_0x24dade(0x1e3),_0x39f36e),this[_0x24dade(0x204)](_0x24dade(0x1fe)+_0x39f36e[_0x24dade(0x1fa)]);}if(this[_0x24dade(0x196)])this[_0x24dade(0x1c0)]('disconnected'),this[_0x24dade(0x204)]('SSE\x20reconnecting\x20in\x20'+_0x49ebb1/0x3e8+_0x24dade(0x1cb)),await this[_0x24dade(0x1d8)](_0x49ebb1),_0x49ebb1=Math[_0x24dade(0x1c7)](_0x49ebb1*1.5,0xea60);}}async['processInbox'](){const _0x76bb32=a0_0x47b98e;try{let _0x5b7bc6=(await this[_0x76bb32(0x1c4)](_0x76bb32(0x1e5),{'alias':this[_0x76bb32(0x199)],'limit':0xa}))?.['messages']||[];for(let _0x43307c of _0x5b7bc6)await this['call'](_0x76bb32(0x1b6),{'alias':this[_0x76bb32(0x199)],'message_id':_0x43307c['id']}),this[_0x76bb32(0x204)]('←\x20'+_0x43307c[_0x76bb32(0x1a4)]+':\x20'+_0x43307c[_0x76bb32(0x1af)]['slice'](0x0,0x3c)),this[_0x76bb32(0x1c0)]('task',_0x43307c),this['emit'](_0x76bb32(0x1fa),_0x43307c);}catch(_0x31992f){this['log'](_0x76bb32(0x1d9)+_0x31992f[_0x76bb32(0x1fa)]);}}['sleep'](_0x568d71){return new Promise(_0x2efb8b=>setTimeout(_0x2efb8b,_0x568d71));}}var F=$;function a0_0x3421(_0x264e4f,_0x567026){_0x264e4f=_0x264e4f-0x185;const _0xbb260d=a0_0xbb26();let _0x3421c7=_0xbb260d[_0x264e4f];return _0x3421c7;}export{F as default,$ as CommHub};
|