@sleep2agi/agent-network 2.3.0-preview.227 → 2.3.0-preview.229

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- function a0_0xea17(){const _0x91977a=['connect','sseAbort','Bearer\x20','disconnected','cwd','completed','status','log','<unknown>','Authorization','duration_ms','error_code','match','send_failed','POST','2743016HOVrBu','report_status','from_alias','content','signal','replace','\x20to=','network_id','url','s...','startsWith','broadcast','heartbeatTimer','agent','CommHub\x20rejected\x20task','token','string','text','toAlias','task','task.send.start','SSE\x20error:\x20','to_alias','connected','/mcp','160zPjIVL','get_inbox','send','name','idle','message_id','task.ack','fromAlias','lifecycle_tracking','failed','catch','slice','transport','getReader','task.send.delivered','parse','result','9eeazls','read','10890495lflFlv','/events/','data:\x20','error','heartbeatInterval','body','lifecycleTracking','server','disconnect','parent_task_id','message','2232027mXLSyF','sdk-','processInbox','task.replied','\x20network_id=','min','SSE\x20reconnecting\x20in\x20','networkId','emit','task.started','running','\x20from=','type','send_reply','call','tools/call','sleep','unknown\x20error','offline','toString','registered','pop','send_rejected','delivered','not_tracked','parentTaskId','task.expired','abort','alias','decode','\x20transport=','\x20duration_ms=','inbox\x20error:\x20','resumeId','text/event-stream','<missing>','heartbeat\x20failed:\x20','\x20error=','5654256YEYPZI','SSE\x20failed:\x20','task_id','45481224RTeRzH','new_task','send_message','77472HvWYrL','autoConnect','json','now','\x20task_id=','735955irAHZT','missing_task_id','new_message','[commhub:task]\x20','send_task'];a0_0xea17=function(){return _0x91977a;};return a0_0xea17();}const a0_0x24b300=a0_0xb6ab;(function(_0x11a11a,_0x4c4014){const _0x2369de=a0_0xb6ab,_0x1d5cb1=_0x11a11a();while(!![]){try{const _0x134ae2=-parseInt(_0x2369de(0xf2))/0x1+-parseInt(_0x2369de(0x106))/0x2+parseInt(_0x2369de(0xc1))/0x3+-parseInt(_0x2369de(0xe7))/0x4+-parseInt(_0x2369de(0xa3))/0x5*(parseInt(_0x2369de(0xed))/0x6)+-parseInt(_0x2369de(0xb6))/0x7+parseInt(_0x2369de(0xea))/0x8*(parseInt(_0x2369de(0xb4))/0x9);if(_0x134ae2===_0x4c4014)break;else _0x1d5cb1['push'](_0x1d5cb1['shift']());}catch(_0x727bd2){_0x1d5cb1['push'](_0x1d5cb1['shift']());}}}(a0_0xea17,0xe549e));import{EventEmitter as a0_0x2ab3f9}from'events';import{hostname as a0_0x44f980}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0xf8afc4,_0x2d79e4)=>(_0xf8afc4??_0x2d79e4)[a0_0x24b300(0x10b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x24b300(0xae)](0x0,0xf0);function N(_0xe5f749){const _0x1fe948=a0_0x24b300;return(_0xe5f749 instanceof Error?_0xe5f749['message']:String(_0xe5f749??_0x1fe948(0xd2)))[_0x1fe948(0x10b)](K,'[REDACTED]')[_0x1fe948(0x10b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x1fe948(0xae)](0x0,0xf0);}function O(_0x53378f,_0x55a51f=process.env.ANET_TASK_TRACE_FORMAT===a0_0x24b300(0xef)){const _0x1ebb7c=a0_0x24b300;if(_0x55a51f)return JSON['stringify'](_0x53378f);let _0x2506b5=L(_0x53378f[_0x1ebb7c(0xbf)],_0x1ebb7c(0xe4)),_0x1e19cc=L(_0x53378f['task_id'],'<pending>'),_0x374992=_0x53378f['error_code']?_0x1ebb7c(0xe6)+_0x53378f[_0x1ebb7c(0x102)]+':'+(_0x53378f['error_message']??''):'';return _0x1ebb7c(0xf5)+_0x53378f[_0x1ebb7c(0xfd)]+_0x1ebb7c(0xcc)+L(_0x53378f[_0x1ebb7c(0x108)],_0x1ebb7c(0xff))+_0x1ebb7c(0x10c)+L(_0x53378f[_0x1ebb7c(0xa0)],_0x1ebb7c(0xff))+_0x1ebb7c(0xf1)+_0x1e19cc+'\x20parent_task_id='+_0x2506b5+_0x1ebb7c(0xc5)+L(_0x53378f[_0x1ebb7c(0x10d)],_0x1ebb7c(0xff))+_0x1ebb7c(0xdf)+_0x53378f[_0x1ebb7c(0xaf)]+_0x1ebb7c(0xe0)+_0x53378f[_0x1ebb7c(0x101)]+'\x20lifecycle='+_0x53378f[_0x1ebb7c(0xab)]+_0x374992;}function U(_0x3a6f42){const _0x560b00=a0_0x24b300;return{'event':{'sending':_0x560b00(0x9e),'delivered':_0x560b00(0xb1),'failed':'task.send.failed','acked':_0x560b00(0xa9),'started':_0x560b00(0xca),'replied':_0x560b00(0xc4),'expired':_0x560b00(0xdb)}[_0x3a6f42['status']],..._0x3a6f42};}function j(_0x179d10){const _0x1778b4=a0_0x24b300;let _0x22ab50=_0x179d10?.[_0x1778b4(0xe9)]||_0x179d10?.['message_id']||_0x179d10?.['id'];if(_0x22ab50)return String(_0x22ab50);let _0x298b12=_0x179d10?.[_0x1778b4(0x109)]?.[0x0]?.[_0x1778b4(0x117)];if(typeof _0x298b12!==_0x1778b4(0x116))return null;try{let _0x56e1f3=JSON['parse'](_0x298b12);return _0x56e1f3?.[_0x1778b4(0xe9)]||_0x56e1f3?.[_0x1778b4(0xa8)]||_0x56e1f3?.['id']||null;}catch{return null;}}async function X(_0x5aba4e,_0x2759a9){const _0x42a548=a0_0x24b300;let _0x25a3aa=_0x2759a9[_0x42a548(0xf0)]??Date['now'],_0x4c1b11=_0x25a3aa(),_0x205d7e=(_0x5c50a8,_0x45a80c,_0x188599,_0x19d1ab)=>{const _0x590f31=_0x42a548;_0x2759a9[_0x590f31(0xfe)](O(U({'from_alias':_0x5aba4e[_0x590f31(0xaa)],'to_alias':_0x5aba4e[_0x590f31(0x118)],'task_id':_0x45a80c,'parent_task_id':_0x5aba4e[_0x590f31(0xda)],'network_id':_0x5aba4e['networkId'],'transport':_0x5aba4e[_0x590f31(0xaf)],'status':_0x5c50a8,'duration_ms':_0x25a3aa()-_0x4c1b11,'lifecycle_tracking':_0x5aba4e[_0x590f31(0xbc)],..._0x188599!==void 0x0?{'error_code':_0x19d1ab||'send_failed','error_message':N(_0x188599)}:{}})));};_0x205d7e('sending',null);try{let _0x1c7b3b=await _0x2759a9[_0x42a548(0xa5)](),_0x5b7e0e=j(_0x1c7b3b);if(_0x5b7e0e)_0x205d7e(_0x42a548(0xd8),_0x5b7e0e);else{if(_0x1c7b3b?.['ok']===!0x1||_0x1c7b3b?.[_0x42a548(0xb9)])_0x205d7e(_0x42a548(0xac),_0x5b7e0e,_0x1c7b3b?.['error']||_0x42a548(0x114),_0x42a548(0xd7));else _0x205d7e(_0x42a548(0xac),null,'CommHub\x20response\x20omitted\x20task_id',_0x42a548(0xf3));}return _0x1c7b3b;}catch(_0x246b79){throw _0x205d7e(_0x42a548(0xac),null,_0x246b79,_0x42a548(0x104)),_0x246b79;}}function a0_0xb6ab(_0x4e5c09,_0x2b528b){_0x4e5c09=_0x4e5c09-0x9e;const _0xea17ab=a0_0xea17();let _0xb6ab27=_0xea17ab[_0x4e5c09];return _0xb6ab27;}async function Y(_0x121547,_0x1db3ea){const _0x40d1b4=a0_0x24b300;return X({'fromAlias':_0x121547['fromAlias'],'toAlias':_0x121547[_0x40d1b4(0xdd)],'parentTaskId':_0x121547[_0x40d1b4(0xda)]||null,'networkId':_0x121547[_0x40d1b4(0xc8)]||null,'transport':'mcp_http','lifecycleTracking':_0x40d1b4(0xd9)},_0x1db3ea);}class $ extends a0_0x2ab3f9{[a0_0x24b300(0x10e)];[a0_0x24b300(0xdd)];['token'];['agent'];[a0_0x24b300(0xe2)];[a0_0x24b300(0xba)];['reconnectDelay'];[a0_0x24b300(0x112)];[a0_0x24b300(0xf8)];[a0_0x24b300(0xcb)]=!0x1;constructor(_0x37aaa9){const _0x48ffcb=a0_0x24b300;super();if(this[_0x48ffcb(0x10e)]=_0x37aaa9[_0x48ffcb(0x10e)][_0x48ffcb(0x10b)](/\/$/,''),this[_0x48ffcb(0xdd)]=_0x37aaa9[_0x48ffcb(0xdd)],this[_0x48ffcb(0x115)]=_0x37aaa9[_0x48ffcb(0x115)],this['agent']=_0x37aaa9[_0x48ffcb(0x113)]||'sdk',this[_0x48ffcb(0xe2)]=_0x48ffcb(0xc2)+_0x37aaa9[_0x48ffcb(0xdd)]+'-'+Date['now']()[_0x48ffcb(0xd4)](0x24),this[_0x48ffcb(0xba)]=_0x37aaa9[_0x48ffcb(0xba)]??0x2bf20,this['reconnectDelay']=_0x37aaa9['reconnectDelay']??0xbb8,_0x37aaa9[_0x48ffcb(0xee)]!==!0x1)this[_0x48ffcb(0xf7)]();}[a0_0x24b300(0xfe)](_0x31f111){const _0x4ca841=a0_0x24b300;console[_0x4ca841(0xfe)]('['+new Date()['toTimeString']()[_0x4ca841(0xae)](0x0,0x8)+']\x20[commhub:'+this['alias']+']\x20'+_0x31f111);}async[a0_0x24b300(0xcf)](_0x455045,_0x161728){const _0x366aea=a0_0x24b300;let _0x2fb344={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this[_0x366aea(0x115)])_0x2fb344[_0x366aea(0x100)]=_0x366aea(0xf9)+this[_0x366aea(0x115)];let _0x56b291=await(await fetch(this[_0x366aea(0x10e)]+_0x366aea(0xa2),{'method':_0x366aea(0x105),'headers':_0x2fb344,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date['now'](),'method':_0x366aea(0xd0),'params':{'name':_0x455045,'arguments':_0x161728}})}))[_0x366aea(0x117)](),_0x34d742=_0x56b291[_0x366aea(0x103)](/data: (.+)/),_0x3f747c=_0x34d742?JSON['parse'](_0x34d742[0x1]):JSON[_0x366aea(0xb2)](_0x56b291),_0x4e3c4=_0x3f747c?.[_0x366aea(0xb3)]?.[_0x366aea(0x109)]?.[0x0]?.[_0x366aea(0x117)];return _0x4e3c4?JSON[_0x366aea(0xb2)](_0x4e3c4):_0x3f747c;}async[a0_0x24b300(0xf7)](){const _0x5530d2=a0_0x24b300;if(this['running'])return;this[_0x5530d2(0xcb)]=!0x0,await this[_0x5530d2(0xfd)](_0x5530d2(0xa7)),this['log'](_0x5530d2(0xd5)),this[_0x5530d2(0x112)]=setInterval(()=>{const _0x2552cb=_0x5530d2;this['status'](_0x2552cb(0xa7))[_0x2552cb(0xad)](_0x13e506=>this['log'](_0x2552cb(0xe5)+_0x13e506[_0x2552cb(0xc0)]));},this[_0x5530d2(0xba)]),this['connectSSE']();}async[a0_0x24b300(0xbe)](){const _0x5f11e5=a0_0x24b300;if(this[_0x5f11e5(0xcb)]=!0x1,this[_0x5f11e5(0xf8)]?.[_0x5f11e5(0xdc)](),this[_0x5f11e5(0x112)])clearInterval(this['heartbeatTimer']);await this[_0x5f11e5(0xfd)](_0x5f11e5(0xd3))['catch'](()=>{}),this[_0x5f11e5(0xfe)](_0x5f11e5(0xfa));}async[a0_0x24b300(0xa5)](_0x50d2b2,_0x5be310,_0x8cbc0f='normal'){const _0x25fbba=a0_0x24b300;return Y({'alias':_0x50d2b2,'fromAlias':this[_0x25fbba(0xdd)]},{'log':_0x52fb50=>console[_0x25fbba(0xfe)](_0x52fb50),'send':()=>this[_0x25fbba(0xcf)](_0x25fbba(0xf6),{'alias':_0x50d2b2,'task':_0x5be310,'priority':_0x8cbc0f,'from_session':this['alias']})});}async[a0_0x24b300(0xc0)](_0x211019,_0x18996f){const _0x28e1b3=a0_0x24b300;return this[_0x28e1b3(0xcf)](_0x28e1b3(0xec),{'alias':_0x211019,'message':_0x18996f,'from_session':this[_0x28e1b3(0xdd)]});}async['reply'](_0x1fbb7c,_0x213c90,_0x4026a5=a0_0x24b300(0xfc)){const _0xc734bc=a0_0x24b300;return this[_0xc734bc(0xcf)](_0xc734bc(0xce),{'in_reply_to':_0x1fbb7c,'text':_0x213c90,'status':_0x4026a5});}async[a0_0x24b300(0xfd)](_0x28a0c0,_0x337e55){const _0x1d1b13=a0_0x24b300;return this['call'](_0x1d1b13(0x107),{'resume_id':this[_0x1d1b13(0xe2)],'alias':this[_0x1d1b13(0xdd)],'status':_0x28a0c0,'server':a0_0x44f980(),'hostname':a0_0x44f980(),'agent':this[_0x1d1b13(0x113)],'project_dir':process[_0x1d1b13(0xfb)](),..._0x337e55});}async['getAllStatus'](){const _0x2b5c9e=a0_0x24b300;return this[_0x2b5c9e(0xcf)]('get_all_status',{});}async['broadcast'](_0xf25a30,_0x5baa88){const _0x4c701a=a0_0x24b300;return this[_0x4c701a(0xcf)](_0x4c701a(0x111),{'message':_0xf25a30,'filter_server':_0x5baa88?.[_0x4c701a(0xbd)],'filter_status':_0x5baa88?.[_0x4c701a(0xfd)]});}async['connectSSE'](){const _0x1404c1=a0_0x24b300;let _0x20aed7=encodeURIComponent(this[_0x1404c1(0xdd)]),_0x2994d2=this['url']+_0x1404c1(0xb7)+_0x20aed7,_0x4c12ac=this['reconnectDelay'];while(this['running']){try{this[_0x1404c1(0xf8)]=new AbortController();let _0x4aacb8={'Accept':_0x1404c1(0xe3)};if(this[_0x1404c1(0x115)])_0x4aacb8['Authorization']=_0x1404c1(0xf9)+this[_0x1404c1(0x115)];let _0x2baf88=await fetch(_0x2994d2,{'headers':_0x4aacb8,'signal':this[_0x1404c1(0xf8)][_0x1404c1(0x10a)]});if(!_0x2baf88['ok']||!_0x2baf88[_0x1404c1(0xbb)]){this[_0x1404c1(0xfe)](_0x1404c1(0xe8)+_0x2baf88[_0x1404c1(0xfd)]),await this[_0x1404c1(0xd1)](_0x4c12ac),_0x4c12ac=Math[_0x1404c1(0xc6)](_0x4c12ac*1.5,0xea60);continue;}_0x4c12ac=this['reconnectDelay'];let _0x4f00c4=_0x2baf88[_0x1404c1(0xbb)][_0x1404c1(0xb0)](),_0x10b856=new TextDecoder(),_0x31e645='';while(this[_0x1404c1(0xcb)]){let {done:_0x1243eb,value:_0xccee76}=await _0x4f00c4[_0x1404c1(0xb5)]();if(_0x1243eb)break;_0x31e645+=_0x10b856[_0x1404c1(0xde)](_0xccee76,{'stream':!0x0});let _0x389f59=_0x31e645['split']('\x0a');_0x31e645=_0x389f59[_0x1404c1(0xd6)]()||'';for(let _0x53b2a6 of _0x389f59){if(!_0x53b2a6[_0x1404c1(0x110)](_0x1404c1(0xb8)))continue;try{let _0x548ef5=JSON[_0x1404c1(0xb2)](_0x53b2a6[_0x1404c1(0xae)](0x6));if(_0x548ef5['type']===_0x1404c1(0xa1)){this['log']('SSE\x20connected'),this['emit'](_0x1404c1(0xa1));continue;}if(_0x548ef5[_0x1404c1(0xcd)]===_0x1404c1(0xeb)||_0x548ef5['type']===_0x1404c1(0xf4)||_0x548ef5[_0x1404c1(0xcd)]===_0x1404c1(0x111))await this['processInbox']();}catch{}}}}catch(_0x5b1c4f){if(_0x5b1c4f[_0x1404c1(0xa6)]==='AbortError')break;this[_0x1404c1(0xc9)](_0x1404c1(0xb9),_0x5b1c4f),this[_0x1404c1(0xfe)](_0x1404c1(0x9f)+_0x5b1c4f[_0x1404c1(0xc0)]);}if(this[_0x1404c1(0xcb)])this['emit'](_0x1404c1(0xfa)),this[_0x1404c1(0xfe)](_0x1404c1(0xc7)+_0x4c12ac/0x3e8+_0x1404c1(0x10f)),await this[_0x1404c1(0xd1)](_0x4c12ac),_0x4c12ac=Math[_0x1404c1(0xc6)](_0x4c12ac*1.5,0xea60);}}async[a0_0x24b300(0xc3)](){const _0x3342ae=a0_0x24b300;try{let _0x160966=(await this[_0x3342ae(0xcf)](_0x3342ae(0xa4),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x480794 of _0x160966)await this[_0x3342ae(0xcf)]('ack_inbox',{'alias':this[_0x3342ae(0xdd)],'message_id':_0x480794['id']}),this[_0x3342ae(0xfe)]('←\x20'+_0x480794['from_session']+':\x20'+_0x480794[_0x3342ae(0x109)][_0x3342ae(0xae)](0x0,0x3c)),this[_0x3342ae(0xc9)](_0x3342ae(0x119),_0x480794),this[_0x3342ae(0xc9)](_0x3342ae(0xc0),_0x480794);}catch(_0x4a9c21){this[_0x3342ae(0xfe)](_0x3342ae(0xe1)+_0x4a9c21[_0x3342ae(0xc0)]);}}['sleep'](_0x4421c2){return new Promise(_0x494e97=>setTimeout(_0x494e97,_0x4421c2));}}var F=$;export{F as default,$ as CommHub};
1
+ function a0_0x2be2(_0x3e391f,_0x12350f){_0x3e391f=_0x3e391f-0xcb;const _0x20cd5e=a0_0x20cd();let _0x2be285=_0x20cd5e[_0x3e391f];return _0x2be285;}const a0_0x5cf1b6=a0_0x2be2;(function(_0x117ca9,_0x4cbdff){const _0xa151a6=a0_0x2be2,_0x8cd9c2=_0x117ca9();while(!![]){try{const _0x9414b9=parseInt(_0xa151a6(0xe1))/0x1+parseInt(_0xa151a6(0x13d))/0x2+-parseInt(_0xa151a6(0xd3))/0x3+parseInt(_0xa151a6(0x112))/0x4+parseInt(_0xa151a6(0xee))/0x5*(-parseInt(_0xa151a6(0x104))/0x6)+parseInt(_0xa151a6(0x101))/0x7+parseInt(_0xa151a6(0x11a))/0x8;if(_0x9414b9===_0x4cbdff)break;else _0x8cd9c2['push'](_0x8cd9c2['shift']());}catch(_0x192a51){_0x8cd9c2['push'](_0x8cd9c2['shift']());}}}(a0_0x20cd,0xa6972));import{EventEmitter as a0_0x416f38}from'events';import{hostname as a0_0x3adae1}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x1957fb,_0x557a61)=>(_0x1957fb??_0x557a61)[a0_0x5cf1b6(0x134)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x3ebce3){const _0x2c125e=a0_0x5cf1b6;return(_0x3ebce3 instanceof Error?_0x3ebce3[_0x2c125e(0xe5)]:String(_0x3ebce3??'unknown\x20error'))['replace'](K,_0x2c125e(0xf3))[_0x2c125e(0x134)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x308dce,_0x3749dd=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5cf1b6(0xf9)){const _0x487890=a0_0x5cf1b6;if(_0x3749dd)return JSON[_0x487890(0xe6)](_0x308dce);let _0xf08c8=L(_0x308dce[_0x487890(0x130)],_0x487890(0xfd)),_0xf8961e=L(_0x308dce[_0x487890(0xd4)],_0x487890(0x118)),_0x3c3934=_0x308dce[_0x487890(0xdf)]?_0x487890(0x10d)+_0x308dce[_0x487890(0xdf)]+':'+(_0x308dce[_0x487890(0xff)]??''):'';return _0x487890(0xdb)+_0x308dce[_0x487890(0x115)]+_0x487890(0xd5)+L(_0x308dce['from_alias'],'<unknown>')+_0x487890(0xf5)+L(_0x308dce[_0x487890(0xda)],'<unknown>')+_0x487890(0x146)+_0xf8961e+'\x20parent_task_id='+_0xf08c8+_0x487890(0x127)+L(_0x308dce[_0x487890(0x116)],_0x487890(0x12b))+_0x487890(0x147)+_0x308dce[_0x487890(0x144)]+_0x487890(0x13c)+_0x308dce[_0x487890(0x143)]+_0x487890(0x133)+_0x308dce[_0x487890(0x136)]+_0x3c3934;}function U(_0x53f472){const _0xc5e292=a0_0x5cf1b6;return{'event':{'sending':'task.send.start','delivered':_0xc5e292(0xd0),'failed':_0xc5e292(0x128),'acked':_0xc5e292(0xd8),'started':'task.started','replied':_0xc5e292(0x12f),'expired':_0xc5e292(0xf1)}[_0x53f472['status']],..._0x53f472};}function a0_0x20cd(){const _0x58166b=['Authorization','heartbeatTimer','type','error_code','split','189774mQtNnQ','/mcp','send_message','sdk-','message','stringify','connectSSE','now','SSE\x20error:\x20','alias','CommHub\x20response\x20omitted\x20task_id','lifecycleTracking','emit','1881935UVwJyh','ack_inbox','sseAbort','task.expired','send_reply','[REDACTED]','normal','\x20to=','error','application/json,\x20text/event-stream','reply','json','registered','slice','abort','<missing>','url','error_message','get_inbox','3422321ZExptD','connect','new_task','6NjmuGM','string','completed','name','pop','s...','Bearer\x20','SSE\x20failed:\x20','from_session','\x20error=','send','CommHub\x20rejected\x20task','parse','min','998460lzQJdZ','failed','tools/call','status','network_id','disconnect','<pending>','token','1710968bFIAGD','mcp_http','networkId','get_all_status','POST','not_tracked','parentTaskId','result','delivered','sleep','startsWith','reconnectDelay','sending','\x20network_id=','task.send.failed','body','call','<unknown>','heartbeat\x20failed:\x20','agent','server','task.replied','parent_task_id','fromAlias','running','\x20lifecycle=','replace','missing_task_id','lifecycle_tracking','resumeId','cwd','log','send_failed','toAlias','\x20duration_ms=','2327510Yknqkt','AbortError','match','toString','content',']\x20[commhub:','duration_ms','transport','catch','\x20task_id=','\x20transport=','new_message','2.0','SSE\x20reconnecting\x20in\x20','heartbeatInterval','idle','task.send.delivered','message_id','inbox\x20error:\x20','3741531DKEURu','task_id','\x20from=','send_task','text','task.ack','connected','to_alias','[commhub:task]\x20'];a0_0x20cd=function(){return _0x58166b;};return a0_0x20cd();}function j(_0x34c5be){const _0x5b92aa=a0_0x5cf1b6;let _0x4c813b=_0x34c5be?.[_0x5b92aa(0xd4)]||_0x34c5be?.[_0x5b92aa(0xd1)]||_0x34c5be?.['id'];if(_0x4c813b)return String(_0x4c813b);let _0x4ebc95=_0x34c5be?.[_0x5b92aa(0x141)]?.[0x0]?.[_0x5b92aa(0xd7)];if(typeof _0x4ebc95!==_0x5b92aa(0x105))return null;try{let _0x1921f7=JSON[_0x5b92aa(0x110)](_0x4ebc95);return _0x1921f7?.[_0x5b92aa(0xd4)]||_0x1921f7?.['message_id']||_0x1921f7?.['id']||null;}catch{return null;}}async function X(_0x5a100f,_0x3900f8){const _0x17b8cc=a0_0x5cf1b6;let _0xb33e=_0x3900f8['now']??Date['now'],_0x45c384=_0xb33e(),_0x303c83=(_0x563ae4,_0x332602,_0x3abeaa,_0x19c1f0)=>{const _0x22044c=a0_0x2be2;_0x3900f8[_0x22044c(0x139)](O(U({'from_alias':_0x5a100f[_0x22044c(0x131)],'to_alias':_0x5a100f[_0x22044c(0x13b)],'task_id':_0x332602,'parent_task_id':_0x5a100f[_0x22044c(0x120)],'network_id':_0x5a100f[_0x22044c(0x11c)],'transport':_0x5a100f[_0x22044c(0x144)],'status':_0x563ae4,'duration_ms':_0xb33e()-_0x45c384,'lifecycle_tracking':_0x5a100f[_0x22044c(0xec)],..._0x3abeaa!==void 0x0?{'error_code':_0x19c1f0||_0x22044c(0x13a),'error_message':N(_0x3abeaa)}:{}})));};_0x303c83(_0x17b8cc(0x126),null);try{let _0x2e0bfc=await _0x3900f8[_0x17b8cc(0x10e)](),_0x5224f9=j(_0x2e0bfc);if(_0x5224f9)_0x303c83(_0x17b8cc(0x122),_0x5224f9);else{if(_0x2e0bfc?.['ok']===!0x1||_0x2e0bfc?.[_0x17b8cc(0xf6)])_0x303c83(_0x17b8cc(0x113),_0x5224f9,_0x2e0bfc?.[_0x17b8cc(0xf6)]||_0x17b8cc(0x10f),'send_rejected');else _0x303c83(_0x17b8cc(0x113),null,_0x17b8cc(0xeb),_0x17b8cc(0x135));}return _0x2e0bfc;}catch(_0x440f4e){throw _0x303c83(_0x17b8cc(0x113),null,_0x440f4e,_0x17b8cc(0x13a)),_0x440f4e;}}async function Y(_0x58c1c6,_0x3a1220){const _0xadb9d3=a0_0x5cf1b6;return X({'fromAlias':_0x58c1c6['fromAlias'],'toAlias':_0x58c1c6[_0xadb9d3(0xea)],'parentTaskId':_0x58c1c6[_0xadb9d3(0x120)]||null,'networkId':_0x58c1c6[_0xadb9d3(0x11c)]||null,'transport':_0xadb9d3(0x11b),'lifecycleTracking':_0xadb9d3(0x11f)},_0x3a1220);}class $ extends a0_0x416f38{[a0_0x5cf1b6(0xfe)];[a0_0x5cf1b6(0xea)];['token'];[a0_0x5cf1b6(0x12d)];[a0_0x5cf1b6(0x137)];[a0_0x5cf1b6(0xce)];['reconnectDelay'];['heartbeatTimer'];['sseAbort'];[a0_0x5cf1b6(0x132)]=!0x1;constructor(_0x482d03){const _0x56c9d4=a0_0x5cf1b6;super();if(this['url']=_0x482d03[_0x56c9d4(0xfe)][_0x56c9d4(0x134)](/\/$/,''),this[_0x56c9d4(0xea)]=_0x482d03[_0x56c9d4(0xea)],this[_0x56c9d4(0x119)]=_0x482d03[_0x56c9d4(0x119)],this['agent']=_0x482d03['agent']||'sdk',this[_0x56c9d4(0x137)]=_0x56c9d4(0xe4)+_0x482d03[_0x56c9d4(0xea)]+'-'+Date[_0x56c9d4(0xe8)]()[_0x56c9d4(0x140)](0x24),this[_0x56c9d4(0xce)]=_0x482d03['heartbeatInterval']??0x2bf20,this[_0x56c9d4(0x125)]=_0x482d03[_0x56c9d4(0x125)]??0xbb8,_0x482d03['autoConnect']!==!0x1)this[_0x56c9d4(0x102)]();}[a0_0x5cf1b6(0x139)](_0x1db1e0){const _0x2e30fd=a0_0x5cf1b6;console['log']('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0x2e30fd(0x142)+this[_0x2e30fd(0xea)]+']\x20'+_0x1db1e0);}async[a0_0x5cf1b6(0x12a)](_0x5a3d22,_0x652bd7){const _0x511cbf=a0_0x5cf1b6;let _0x4d8ed3={'Content-Type':'application/json','Accept':_0x511cbf(0xf7)};if(this[_0x511cbf(0x119)])_0x4d8ed3[_0x511cbf(0xdc)]=_0x511cbf(0x10a)+this[_0x511cbf(0x119)];let _0x174912=await(await fetch(this['url']+_0x511cbf(0xe2),{'method':_0x511cbf(0x11e),'headers':_0x4d8ed3,'body':JSON[_0x511cbf(0xe6)]({'jsonrpc':_0x511cbf(0xcc),'id':Date[_0x511cbf(0xe8)](),'method':_0x511cbf(0x114),'params':{'name':_0x5a3d22,'arguments':_0x652bd7}})}))[_0x511cbf(0xd7)](),_0x527f91=_0x174912[_0x511cbf(0x13f)](/data: (.+)/),_0x3de943=_0x527f91?JSON[_0x511cbf(0x110)](_0x527f91[0x1]):JSON[_0x511cbf(0x110)](_0x174912),_0x371256=_0x3de943?.[_0x511cbf(0x121)]?.[_0x511cbf(0x141)]?.[0x0]?.['text'];return _0x371256?JSON[_0x511cbf(0x110)](_0x371256):_0x3de943;}async['connect'](){const _0x50bb4b=a0_0x5cf1b6;if(this[_0x50bb4b(0x132)])return;this[_0x50bb4b(0x132)]=!0x0,await this[_0x50bb4b(0x115)](_0x50bb4b(0xcf)),this['log'](_0x50bb4b(0xfa)),this[_0x50bb4b(0xdd)]=setInterval(()=>{const _0x45aa40=_0x50bb4b;this[_0x45aa40(0x115)](_0x45aa40(0xcf))[_0x45aa40(0x145)](_0x1bf4f6=>this['log'](_0x45aa40(0x12c)+_0x1bf4f6[_0x45aa40(0xe5)]));},this[_0x50bb4b(0xce)]),this[_0x50bb4b(0xe7)]();}async[a0_0x5cf1b6(0x117)](){const _0x4012fa=a0_0x5cf1b6;if(this['running']=!0x1,this['sseAbort']?.[_0x4012fa(0xfc)](),this['heartbeatTimer'])clearInterval(this[_0x4012fa(0xdd)]);await this['status']('offline')[_0x4012fa(0x145)](()=>{}),this[_0x4012fa(0x139)]('disconnected');}async['send'](_0x3143f2,_0x3b0256,_0x55ad53=a0_0x5cf1b6(0xf4)){const _0x166c2b=a0_0x5cf1b6;return Y({'alias':_0x3143f2,'fromAlias':this[_0x166c2b(0xea)]},{'log':_0x57b14e=>console[_0x166c2b(0x139)](_0x57b14e),'send':()=>this['call'](_0x166c2b(0xd6),{'alias':_0x3143f2,'task':_0x3b0256,'priority':_0x55ad53,'from_session':this[_0x166c2b(0xea)]})});}async[a0_0x5cf1b6(0xe5)](_0x2099ff,_0x185f23){const _0x5b3252=a0_0x5cf1b6;return this[_0x5b3252(0x12a)](_0x5b3252(0xe3),{'alias':_0x2099ff,'message':_0x185f23,'from_session':this[_0x5b3252(0xea)]});}async[a0_0x5cf1b6(0xf8)](_0x583efa,_0x177772,_0x23a412=a0_0x5cf1b6(0x106)){const _0x5c9064=a0_0x5cf1b6;return this[_0x5c9064(0x12a)](_0x5c9064(0xf2),{'in_reply_to':_0x583efa,'text':_0x177772,'status':_0x23a412});}async[a0_0x5cf1b6(0x115)](_0x156c1f,_0x379f5f){const _0x96d09c=a0_0x5cf1b6;return this[_0x96d09c(0x12a)]('report_status',{'resume_id':this[_0x96d09c(0x137)],'alias':this[_0x96d09c(0xea)],'status':_0x156c1f,'server':a0_0x3adae1(),'hostname':a0_0x3adae1(),'agent':this['agent'],'project_dir':process[_0x96d09c(0x138)](),..._0x379f5f});}async['getAllStatus'](){const _0x14a8f4=a0_0x5cf1b6;return this['call'](_0x14a8f4(0x11d),{});}async['broadcast'](_0x1301fa,_0x187b3a){const _0xbe541f=a0_0x5cf1b6;return this['call']('broadcast',{'message':_0x1301fa,'filter_server':_0x187b3a?.[_0xbe541f(0x12e)],'filter_status':_0x187b3a?.[_0xbe541f(0x115)]});}async[a0_0x5cf1b6(0xe7)](){const _0x1d82b7=a0_0x5cf1b6;let _0x385c8f=encodeURIComponent(this['alias']),_0x573d9f=this[_0x1d82b7(0xfe)]+'/events/'+_0x385c8f,_0x3130e3=this[_0x1d82b7(0x125)];while(this['running']){try{this[_0x1d82b7(0xf0)]=new AbortController();let _0x32f062={'Accept':'text/event-stream'};if(this[_0x1d82b7(0x119)])_0x32f062[_0x1d82b7(0xdc)]=_0x1d82b7(0x10a)+this[_0x1d82b7(0x119)];let _0x5dbd34=await fetch(_0x573d9f,{'headers':_0x32f062,'signal':this['sseAbort']['signal']});if(!_0x5dbd34['ok']||!_0x5dbd34[_0x1d82b7(0x129)]){this[_0x1d82b7(0x139)](_0x1d82b7(0x10b)+_0x5dbd34[_0x1d82b7(0x115)]),await this[_0x1d82b7(0x123)](_0x3130e3),_0x3130e3=Math[_0x1d82b7(0x111)](_0x3130e3*1.5,0xea60);continue;}_0x3130e3=this['reconnectDelay'];let _0x53569f=_0x5dbd34[_0x1d82b7(0x129)]['getReader'](),_0x58357c=new TextDecoder(),_0x5e8638='';while(this[_0x1d82b7(0x132)]){let {done:_0x5f37f5,value:_0x19f2a6}=await _0x53569f['read']();if(_0x5f37f5)break;_0x5e8638+=_0x58357c['decode'](_0x19f2a6,{'stream':!0x0});let _0x3e22e1=_0x5e8638[_0x1d82b7(0xe0)]('\x0a');_0x5e8638=_0x3e22e1[_0x1d82b7(0x108)]()||'';for(let _0x4deb78 of _0x3e22e1){if(!_0x4deb78[_0x1d82b7(0x124)]('data:\x20'))continue;try{let _0x47e66e=JSON[_0x1d82b7(0x110)](_0x4deb78[_0x1d82b7(0xfb)](0x6));if(_0x47e66e[_0x1d82b7(0xde)]===_0x1d82b7(0xd9)){this[_0x1d82b7(0x139)]('SSE\x20connected'),this[_0x1d82b7(0xed)](_0x1d82b7(0xd9));continue;}if(_0x47e66e[_0x1d82b7(0xde)]===_0x1d82b7(0x103)||_0x47e66e[_0x1d82b7(0xde)]===_0x1d82b7(0xcb)||_0x47e66e['type']==='broadcast')await this['processInbox']();}catch{}}}}catch(_0x143612){if(_0x143612[_0x1d82b7(0x107)]===_0x1d82b7(0x13e))break;this[_0x1d82b7(0xed)](_0x1d82b7(0xf6),_0x143612),this[_0x1d82b7(0x139)](_0x1d82b7(0xe9)+_0x143612[_0x1d82b7(0xe5)]);}if(this['running'])this[_0x1d82b7(0xed)]('disconnected'),this[_0x1d82b7(0x139)](_0x1d82b7(0xcd)+_0x3130e3/0x3e8+_0x1d82b7(0x109)),await this['sleep'](_0x3130e3),_0x3130e3=Math['min'](_0x3130e3*1.5,0xea60);}}async['processInbox'](){const _0xb5aa7d=a0_0x5cf1b6;try{let _0x30b526=(await this['call'](_0xb5aa7d(0x100),{'alias':this[_0xb5aa7d(0xea)],'limit':0xa}))?.['messages']||[];for(let _0x422b34 of _0x30b526)await this[_0xb5aa7d(0x12a)](_0xb5aa7d(0xef),{'alias':this['alias'],'message_id':_0x422b34['id']}),this['log']('←\x20'+_0x422b34[_0xb5aa7d(0x10c)]+':\x20'+_0x422b34[_0xb5aa7d(0x141)]['slice'](0x0,0x3c)),this[_0xb5aa7d(0xed)]('task',_0x422b34),this['emit'](_0xb5aa7d(0xe5),_0x422b34);}catch(_0x33afee){this['log'](_0xb5aa7d(0xd2)+_0x33afee[_0xb5aa7d(0xe5)]);}}[a0_0x5cf1b6(0x123)](_0x33a155){return new Promise(_0x460c2c=>setTimeout(_0x460c2c,_0x33a155));}}var F=$;export{F as default,$ as CommHub};
@@ -0,0 +1,74 @@
1
+ export declare const NODE_PERM_MODES: readonly ["normal", "readonly", "restricted"];
2
+ export type NodePermMode = (typeof NODE_PERM_MODES)[number];
3
+ export declare const NODE_PERM_USAGE = "Usage: anet node perm <node> [--json]\n anet node perm <node> [--mode normal|readonly|restricted]\n [--peers <a,b,\u2026>|none] [--peers-add <x>] [--peers-remove <x>]\n [--inbox <a,user:bob,\u2026>|none] [--inbox-add <x>] [--inbox-remove <x>]\n [--hub <url>] [--json]\n\nShow or change a node's permissions on the Hub.\n\n --mode normal | readonly | restricted\n --peers send-to allowlist: who this node may dispatch to (alias or node_id)\n --inbox receive-from allowlist: who may send tasks/messages to this node\n <alias> | <node_id> an agent\n user:<username> | user:<id> a person (Dashboard / app)\n user:* any person\n !strict also require the node's owner and\n network owner/admin to be listed\n none clears that allowlist (no restriction)\n --*-add/--*-remove edit one entry; removing the last entry is refused (use none)\n\n<node> is a local node name, a node_id, or a Hub alias. Changes need your user\nlogin (anet login) as the node's owner or a network owner/admin.\nWithout a change flag it only prints the current settings.\n\nExamples:\n anet node perm reviewer\n anet node perm reviewer --inbox planner,user:alice\n anet node perm reviewer --inbox-add user:bob\n anet node perm reviewer --peers none --mode normal --json";
4
+ type ListEdit = {
5
+ set: string[] | null;
6
+ } | {
7
+ add: string[];
8
+ remove: string[];
9
+ };
10
+ export type NodePermArgs = {
11
+ ref: string;
12
+ json: boolean;
13
+ hub?: string;
14
+ mode?: NodePermMode;
15
+ peers?: ListEdit;
16
+ inbox?: ListEdit;
17
+ };
18
+ export type NodePermState = {
19
+ node_id: string;
20
+ alias: string | null;
21
+ network_id: string | null;
22
+ permission_mode: string;
23
+ peer_allowlist: string[] | null;
24
+ /** undefined = this Hub does not know inbox allowlists yet (no node_inbox_allowlist capability). */
25
+ inbox_allowlist: string[] | null | undefined;
26
+ tool_allowlist: string[] | null;
27
+ rest_allowlist: string[] | null;
28
+ can_set_mode: boolean | null;
29
+ };
30
+ export declare function parseNodePermArgs(argv: string[]): {
31
+ ok: true;
32
+ args: NodePermArgs;
33
+ } | {
34
+ ok: false;
35
+ error: string;
36
+ };
37
+ export declare function hasNodePermChange(args: NodePermArgs): boolean;
38
+ /** Apply an edit to the current list. Returns the list to PUT (null = clear), or an error. */
39
+ export declare function applyListEdit(current: string[] | null, edit: ListEdit, label: string): {
40
+ ok: true;
41
+ next: string[] | null;
42
+ } | {
43
+ ok: false;
44
+ error: string;
45
+ };
46
+ export declare function stateFromNodeRow(row: Record<string, any>): NodePermState;
47
+ export declare function formatNodePerm(s: NodePermState): string[];
48
+ type HubCtx = {
49
+ hub: string;
50
+ token: string;
51
+ fetchImpl?: typeof fetch;
52
+ timeoutMs?: number;
53
+ };
54
+ export declare function describeHubFailure(status: number, body: any, what: string): string;
55
+ /** Find the node on the Hub: exact node_id first, then alias (must be unique across the networks you can see). */
56
+ export declare function findHubNode(ctx: HubCtx, ref: string, localNodeId?: string): Promise<{
57
+ ok: true;
58
+ row: Record<string, any>;
59
+ } | {
60
+ ok: false;
61
+ error: string;
62
+ }>;
63
+ export type NodePermResult = {
64
+ ok: true;
65
+ state: NodePermState;
66
+ changed: string[];
67
+ } | {
68
+ ok: false;
69
+ error: string;
70
+ state?: NodePermState;
71
+ changed?: string[];
72
+ };
73
+ export declare function runNodePerm(ctx: HubCtx, args: NodePermArgs, localNodeId?: string): Promise<NodePermResult>;
74
+ export {};