@sleep2agi/agent-network 2.3.0-preview.70 → 2.3.0-preview.72
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_0x2b4667=a0_0x3544;function a0_0x3544(_0x4457c7,_0x1a17ca){_0x4457c7=_0x4457c7-0xba;const _0x54b653=a0_0x54b6();let _0x3544c5=_0x54b653[_0x4457c7];return _0x3544c5;}(function(_0x17732e,_0x3ab4bb){const _0x269eb9=a0_0x3544,_0x53073c=_0x17732e();while(!![]){try{const _0x2f71b2=-parseInt(_0x269eb9(0xc4))/0x1+-parseInt(_0x269eb9(0x12a))/0x2+parseInt(_0x269eb9(0xfd))/0x3+parseInt(_0x269eb9(0x11b))/0x4*(parseInt(_0x269eb9(0xd3))/0x5)+parseInt(_0x269eb9(0xe2))/0x6*(parseInt(_0x269eb9(0xf5))/0x7)+-parseInt(_0x269eb9(0xc3))/0x8+parseInt(_0x269eb9(0xda))/0x9;if(_0x2f71b2===_0x3ab4bb)break;else _0x53073c['push'](_0x53073c['shift']());}catch(_0x1c9b5e){_0x53073c['push'](_0x53073c['shift']());}}}(a0_0x54b6,0x6eee3));import{EventEmitter as a0_0x2dfb31}from'events';import{hostname as a0_0x10acf7}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4e8f9,_0x1dafd4)=>(_0x4e8f9??_0x1dafd4)[a0_0x2b4667(0xd9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x2b4667(0x10f)](0x0,0xf0);function N(_0x1d1193){const _0x27a759=a0_0x2b4667;return(_0x1d1193 instanceof Error?_0x1d1193['message']:String(_0x1d1193??_0x27a759(0x139)))[_0x27a759(0xd9)](K,_0x27a759(0xf2))[_0x27a759(0xd9)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x27a759(0x10f)](0x0,0xf0);}function O(_0x2d7f24,_0x67262d=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2b4667(0xea)){const _0x347e4e=a0_0x2b4667;if(_0x67262d)return JSON[_0x347e4e(0x11f)](_0x2d7f24);let _0x3caf55=L(_0x2d7f24[_0x347e4e(0xc6)],_0x347e4e(0xeb)),_0x1f2df1=L(_0x2d7f24[_0x347e4e(0x10a)],_0x347e4e(0x128)),_0x4628ea=_0x2d7f24[_0x347e4e(0xca)]?'\x20error='+_0x2d7f24['error_code']+':'+(_0x2d7f24[_0x347e4e(0xe5)]??''):'';return'[commhub:task]\x20'+_0x2d7f24[_0x347e4e(0xc5)]+'\x20from='+L(_0x2d7f24[_0x347e4e(0x122)],_0x347e4e(0xd7))+_0x347e4e(0xd0)+L(_0x2d7f24[_0x347e4e(0x114)],_0x347e4e(0xd7))+_0x347e4e(0x100)+_0x1f2df1+_0x347e4e(0x13a)+_0x3caf55+_0x347e4e(0xd8)+L(_0x2d7f24[_0x347e4e(0x126)],_0x347e4e(0xd7))+_0x347e4e(0x133)+_0x2d7f24[_0x347e4e(0xdd)]+_0x347e4e(0xfe)+_0x2d7f24[_0x347e4e(0x106)]+_0x347e4e(0xf6)+_0x2d7f24['lifecycle_tracking']+_0x4628ea;}function U(_0x48cb8c){const _0xadbd9c=a0_0x2b4667;return{'event':{'sending':_0xadbd9c(0xed),'delivered':_0xadbd9c(0xc8),'failed':_0xadbd9c(0xf1),'acked':_0xadbd9c(0xd6),'started':_0xadbd9c(0x10b),'replied':_0xadbd9c(0x103),'expired':'task.expired'}[_0x48cb8c[_0xadbd9c(0xc5)]],..._0x48cb8c};}function j(_0x24bc89){const _0x100450=a0_0x2b4667;let _0x5dc550=_0x24bc89?.[_0x100450(0x10a)]||_0x24bc89?.[_0x100450(0xfb)]||_0x24bc89?.['id'];if(_0x5dc550)return String(_0x5dc550);let _0xb141c5=_0x24bc89?.['content']?.[0x0]?.[_0x100450(0x12e)];if(typeof _0xb141c5!==_0x100450(0x123))return null;try{let _0x508ba7=JSON[_0x100450(0x109)](_0xb141c5);return _0x508ba7?.['task_id']||_0x508ba7?.[_0x100450(0xfb)]||_0x508ba7?.['id']||null;}catch{return null;}}async function X(_0x1c6f0a,_0x4a44ad){const _0x27e6be=a0_0x2b4667;let _0x59b767=_0x4a44ad[_0x27e6be(0xe8)]??Date[_0x27e6be(0xe8)],_0x4f1e7a=_0x59b767(),_0x5c98af=(_0x214e87,_0x5af6be,_0x233477,_0x3dc598)=>{const _0x22d346=_0x27e6be;_0x4a44ad['log'](O(U({'from_alias':_0x1c6f0a[_0x22d346(0xf0)],'to_alias':_0x1c6f0a[_0x22d346(0xd2)],'task_id':_0x5af6be,'parent_task_id':_0x1c6f0a[_0x22d346(0x132)],'network_id':_0x1c6f0a[_0x22d346(0x11c)],'transport':_0x1c6f0a[_0x22d346(0xdd)],'status':_0x214e87,'duration_ms':_0x59b767()-_0x4f1e7a,'lifecycle_tracking':_0x1c6f0a[_0x22d346(0x129)],..._0x233477!==void 0x0?{'error_code':_0x3dc598||_0x22d346(0x10d),'error_message':N(_0x233477)}:{}})));};_0x5c98af('sending',null);try{let _0x4c960d=await _0x4a44ad[_0x27e6be(0x117)](),_0xc85dc8=j(_0x4c960d);if(_0xc85dc8)_0x5c98af('delivered',_0xc85dc8);else{if(_0x4c960d?.['ok']===!0x1||_0x4c960d?.[_0x27e6be(0x111)])_0x5c98af(_0x27e6be(0x127),_0xc85dc8,_0x4c960d?.[_0x27e6be(0x111)]||_0x27e6be(0xcc),_0x27e6be(0x113));else _0x5c98af('failed',null,_0x27e6be(0xef),_0x27e6be(0x105));}return _0x4c960d;}catch(_0x3d2491){throw _0x5c98af(_0x27e6be(0x127),null,_0x3d2491,_0x27e6be(0x10d)),_0x3d2491;}}async function Y(_0x42b534,_0x221594){const _0x21b8a1=a0_0x2b4667;return X({'fromAlias':_0x42b534['fromAlias'],'toAlias':_0x42b534[_0x21b8a1(0x131)],'parentTaskId':_0x42b534[_0x21b8a1(0x132)]||null,'networkId':_0x42b534[_0x21b8a1(0x11c)]||null,'transport':'mcp_http','lifecycleTracking':_0x21b8a1(0xc2)},_0x221594);}class $ extends a0_0x2dfb31{[a0_0x2b4667(0xf8)];['alias'];[a0_0x2b4667(0x10c)];[a0_0x2b4667(0xd5)];[a0_0x2b4667(0xcf)];[a0_0x2b4667(0xde)];[a0_0x2b4667(0xdc)];[a0_0x2b4667(0x125)];[a0_0x2b4667(0xce)];[a0_0x2b4667(0xbc)]=!0x1;constructor(_0x4d0237){const _0x305694=a0_0x2b4667;super();if(this[_0x305694(0xf8)]=_0x4d0237[_0x305694(0xf8)][_0x305694(0xd9)](/\/$/,''),this[_0x305694(0x131)]=_0x4d0237['alias'],this['token']=_0x4d0237[_0x305694(0x10c)],this['agent']=_0x4d0237[_0x305694(0xd5)]||_0x305694(0xc9),this[_0x305694(0xcf)]=_0x305694(0x119)+_0x4d0237[_0x305694(0x131)]+'-'+Date[_0x305694(0xe8)]()[_0x305694(0x108)](0x24),this[_0x305694(0xde)]=_0x4d0237[_0x305694(0xde)]??0x2bf20,this[_0x305694(0xdc)]=_0x4d0237[_0x305694(0xdc)]??0xbb8,_0x4d0237[_0x305694(0x102)]!==!0x1)this['connect']();}[a0_0x2b4667(0xdf)](_0x4a8835){const _0x1e6a12=a0_0x2b4667;console[_0x1e6a12(0xdf)]('['+new Date()[_0x1e6a12(0x116)]()[_0x1e6a12(0x10f)](0x0,0x8)+_0x1e6a12(0x13b)+this[_0x1e6a12(0x131)]+']\x20'+_0x4a8835);}async[a0_0x2b4667(0x135)](_0x383540,_0x271f6c){const _0x421165=a0_0x2b4667;let _0x53662b={'Content-Type':'application/json','Accept':'application/json,\x20text/event-stream'};if(this['token'])_0x53662b[_0x421165(0x11d)]='Bearer\x20'+this['token'];let _0x13cfd7=await(await fetch(this[_0x421165(0xf8)]+_0x421165(0xff),{'method':_0x421165(0x12b),'headers':_0x53662b,'body':JSON[_0x421165(0x11f)]({'jsonrpc':_0x421165(0x130),'id':Date[_0x421165(0xe8)](),'method':_0x421165(0xfa),'params':{'name':_0x383540,'arguments':_0x271f6c}})}))[_0x421165(0x12e)](),_0x3a11f7=_0x13cfd7['match'](/data: (.+)/),_0x112073=_0x3a11f7?JSON[_0x421165(0x109)](_0x3a11f7[0x1]):JSON['parse'](_0x13cfd7),_0x5cdf90=_0x112073?.[_0x421165(0xba)]?.[_0x421165(0x110)]?.[0x0]?.[_0x421165(0x12e)];return _0x5cdf90?JSON[_0x421165(0x109)](_0x5cdf90):_0x112073;}async[a0_0x2b4667(0xdb)](){const _0x281715=a0_0x2b4667;if(this[_0x281715(0xbc)])return;this[_0x281715(0xbc)]=!0x0,await this[_0x281715(0xc5)](_0x281715(0x134)),this[_0x281715(0xdf)]('registered'),this[_0x281715(0x125)]=setInterval(()=>{const _0x2ab521=_0x281715;this['status'](_0x2ab521(0x134))[_0x2ab521(0x107)](_0x31266f=>this[_0x2ab521(0xdf)](_0x2ab521(0xe3)+_0x31266f['message']));},this[_0x281715(0xde)]),this[_0x281715(0x12c)]();}async[a0_0x2b4667(0xe1)](){const _0x53014b=a0_0x2b4667;if(this['running']=!0x1,this[_0x53014b(0xce)]?.['abort'](),this[_0x53014b(0x125)])clearInterval(this[_0x53014b(0x125)]);await this[_0x53014b(0xc5)](_0x53014b(0xec))[_0x53014b(0x107)](()=>{}),this[_0x53014b(0xdf)](_0x53014b(0xe6));}async[a0_0x2b4667(0x117)](_0x428c90,_0x183259,_0xd33d03=a0_0x2b4667(0x121)){const _0x24a7c0=a0_0x2b4667;return Y({'alias':_0x428c90,'fromAlias':this[_0x24a7c0(0x131)]},{'log':_0x29c2a6=>console[_0x24a7c0(0xdf)](_0x29c2a6),'send':()=>this['call'](_0x24a7c0(0xbd),{'alias':_0x428c90,'task':_0x183259,'priority':_0xd33d03,'from_session':this[_0x24a7c0(0x131)]})});}async[a0_0x2b4667(0x120)](_0x1d2f64,_0x2a5afe){const _0x546c02=a0_0x2b4667;return this[_0x546c02(0x135)](_0x546c02(0x112),{'alias':_0x1d2f64,'message':_0x2a5afe,'from_session':this[_0x546c02(0x131)]});}async[a0_0x2b4667(0x101)](_0xe1c92d,_0x3c928f,_0x3e245e=a0_0x2b4667(0xf3)){const _0x26e87f=a0_0x2b4667;return this[_0x26e87f(0x135)](_0x26e87f(0x136),{'in_reply_to':_0xe1c92d,'text':_0x3c928f,'status':_0x3e245e});}async[a0_0x2b4667(0xc5)](_0x56cd81,_0x4a84d2){const _0x5eff87=a0_0x2b4667;return this[_0x5eff87(0x135)](_0x5eff87(0xbb),{'resume_id':this['resumeId'],'alias':this[_0x5eff87(0x131)],'status':_0x56cd81,'server':a0_0x10acf7(),'hostname':a0_0x10acf7(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x4a84d2});}async[a0_0x2b4667(0xbe)](){const _0x4ceb76=a0_0x2b4667;return this[_0x4ceb76(0x135)](_0x4ceb76(0x115),{});}async['broadcast'](_0x346c07,_0x58e48f){const _0x4447bc=a0_0x2b4667;return this['call'](_0x4447bc(0x118),{'message':_0x346c07,'filter_server':_0x58e48f?.['server'],'filter_status':_0x58e48f?.[_0x4447bc(0xc5)]});}async[a0_0x2b4667(0x12c)](){const _0x140660=a0_0x2b4667;let _0x91af80=encodeURIComponent(this[_0x140660(0x131)]),_0xec7f36=this['url']+'/events/'+_0x91af80,_0x20f615=this[_0x140660(0xdc)];while(this[_0x140660(0xbc)]){try{this[_0x140660(0xce)]=new AbortController();let _0x1f91d6={'Accept':_0x140660(0x11a)};if(this[_0x140660(0x10c)])_0x1f91d6[_0x140660(0x11d)]='Bearer\x20'+this[_0x140660(0x10c)];let _0x1e84fa=await fetch(_0xec7f36,{'headers':_0x1f91d6,'signal':this[_0x140660(0xce)]['signal']});if(!_0x1e84fa['ok']||!_0x1e84fa[_0x140660(0xf7)]){this[_0x140660(0xdf)]('SSE\x20failed:\x20'+_0x1e84fa[_0x140660(0xc5)]),await this[_0x140660(0x10e)](_0x20f615),_0x20f615=Math[_0x140660(0x104)](_0x20f615*1.5,0xea60);continue;}_0x20f615=this['reconnectDelay'];let _0x110cda=_0x1e84fa['body'][_0x140660(0x137)](),_0x38e757=new TextDecoder(),_0x50c4c5='';while(this[_0x140660(0xbc)]){let {done:_0xd65249,value:_0x48d4fd}=await _0x110cda['read']();if(_0xd65249)break;_0x50c4c5+=_0x38e757[_0x140660(0xe9)](_0x48d4fd,{'stream':!0x0});let _0x33ce16=_0x50c4c5[_0x140660(0xc0)]('\x0a');_0x50c4c5=_0x33ce16[_0x140660(0xc7)]()||'';for(let _0x40ace3 of _0x33ce16){if(!_0x40ace3[_0x140660(0xd1)](_0x140660(0x12d)))continue;try{let _0x5e978f=JSON['parse'](_0x40ace3[_0x140660(0x10f)](0x6));if(_0x5e978f[_0x140660(0xee)]===_0x140660(0x124)){this[_0x140660(0xdf)](_0x140660(0xf9)),this[_0x140660(0xcd)](_0x140660(0x124));continue;}if(_0x5e978f[_0x140660(0xee)]===_0x140660(0xcb)||_0x5e978f['type']==='new_message'||_0x5e978f[_0x140660(0xee)]===_0x140660(0x118))await this[_0x140660(0xe7)]();}catch{}}}}catch(_0x2ba21b){if(_0x2ba21b[_0x140660(0x11e)]===_0x140660(0xfc))break;this[_0x140660(0xcd)](_0x140660(0x111),_0x2ba21b),this['log'](_0x140660(0xc1)+_0x2ba21b['message']);}if(this[_0x140660(0xbc)])this[_0x140660(0xcd)](_0x140660(0xe6)),this[_0x140660(0xdf)](_0x140660(0x138)+_0x20f615/0x3e8+_0x140660(0xbf)),await this['sleep'](_0x20f615),_0x20f615=Math[_0x140660(0x104)](_0x20f615*1.5,0xea60);}}async['processInbox'](){const _0x2e9632=a0_0x2b4667;try{let _0x4a8a95=(await this['call'](_0x2e9632(0xd4),{'alias':this[_0x2e9632(0x131)],'limit':0xa}))?.['messages']||[];for(let _0x47c9c1 of _0x4a8a95)await this['call'](_0x2e9632(0x12f),{'alias':this[_0x2e9632(0x131)],'message_id':_0x47c9c1['id']}),this[_0x2e9632(0xdf)]('←\x20'+_0x47c9c1[_0x2e9632(0xf4)]+':\x20'+_0x47c9c1['content'][_0x2e9632(0x10f)](0x0,0x3c)),this['emit'](_0x2e9632(0xe0),_0x47c9c1),this[_0x2e9632(0xcd)](_0x2e9632(0x120),_0x47c9c1);}catch(_0x219806){this[_0x2e9632(0xdf)](_0x2e9632(0xe4)+_0x219806['message']);}}[a0_0x2b4667(0x10e)](_0x1c81a2){return new Promise(_0x1e572d=>setTimeout(_0x1e572d,_0x1c81a2));}}var F=$;export{F as default,$ as CommHub};function a0_0x54b6(){const _0x11ed58=['startsWith','toAlias','1892615QYgPWy','get_inbox','agent','task.ack','<unknown>','\x20network_id=','replace','12066372xTcWHd','connect','reconnectDelay','transport','heartbeatInterval','log','task','disconnect','78XFnEaW','heartbeat\x20failed:\x20','inbox\x20error:\x20','error_message','disconnected','processInbox','now','decode','json','<missing>','offline','task.send.start','type','CommHub\x20response\x20omitted\x20task_id','fromAlias','task.send.failed','[REDACTED]','completed','from_session','16457QoWVXx','\x20lifecycle=','body','url','SSE\x20connected','tools/call','message_id','AbortError','1404675WQgPAU','\x20duration_ms=','/mcp','\x20task_id=','reply','autoConnect','task.replied','min','missing_task_id','duration_ms','catch','toString','parse','task_id','task.started','token','send_failed','sleep','slice','content','error','send_message','send_rejected','to_alias','get_all_status','toTimeString','send','broadcast','sdk-','text/event-stream','4Umzxtc','networkId','Authorization','name','stringify','message','normal','from_alias','string','connected','heartbeatTimer','network_id','failed','<pending>','lifecycleTracking','1756376WUCfxS','POST','connectSSE','data:\x20','text','ack_inbox','2.0','alias','parentTaskId','\x20transport=','idle','call','send_reply','getReader','SSE\x20reconnecting\x20in\x20','unknown\x20error','\x20parent_task_id=',']\x20[commhub:','result','report_status','running','send_task','getAllStatus','s...','split','SSE\x20error:\x20','not_tracked','652280kbqGIm','803925sUnTkh','status','parent_task_id','pop','task.send.delivered','sdk','error_code','new_task','CommHub\x20rejected\x20task','emit','sseAbort','resumeId','\x20to='];a0_0x54b6=function(){return _0x11ed58;};return a0_0x54b6();}
|
|
1
|
+
const a0_0x32c978=a0_0xf4d6;(function(_0x4b69d5,_0x4d3b29){const _0x4838bf=a0_0xf4d6,_0x19fef6=_0x4b69d5();while(!![]){try{const _0x10c0ed=parseInt(_0x4838bf(0x24e))/0x1+-parseInt(_0x4838bf(0x233))/0x2+-parseInt(_0x4838bf(0x206))/0x3*(parseInt(_0x4838bf(0x23e))/0x4)+-parseInt(_0x4838bf(0x215))/0x5*(-parseInt(_0x4838bf(0x207))/0x6)+parseInt(_0x4838bf(0x223))/0x7*(-parseInt(_0x4838bf(0x1ed))/0x8)+parseInt(_0x4838bf(0x23d))/0x9*(-parseInt(_0x4838bf(0x221))/0xa)+parseInt(_0x4838bf(0x246))/0xb*(parseInt(_0x4838bf(0x229))/0xc);if(_0x10c0ed===_0x4d3b29)break;else _0x19fef6['push'](_0x19fef6['shift']());}catch(_0x4a05a6){_0x19fef6['push'](_0x19fef6['shift']());}}}(a0_0x3b90,0x2080b));import{EventEmitter as a0_0x39481c}from'events';import{hostname as a0_0x415061}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x367d1c,_0x588c77)=>(_0x367d1c??_0x588c77)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x20abaf){const _0x45c6a4=a0_0xf4d6;return(_0x20abaf instanceof Error?_0x20abaf[_0x45c6a4(0x1eb)]:String(_0x20abaf??_0x45c6a4(0x25b)))[_0x45c6a4(0x25a)](K,_0x45c6a4(0x22d))[_0x45c6a4(0x25a)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x45c6a4(0x25f)](0x0,0xf0);}function O(_0x165478,_0x21b4b3=process.env.ANET_TASK_TRACE_FORMAT===a0_0x32c978(0x24b)){const _0x201bcf=a0_0x32c978;if(_0x21b4b3)return JSON['stringify'](_0x165478);let _0x4b18c=L(_0x165478[_0x201bcf(0x20d)],'<missing>'),_0x13748e=L(_0x165478['task_id'],_0x201bcf(0x1f1)),_0x5a3f6c=_0x165478[_0x201bcf(0x1f8)]?_0x201bcf(0x245)+_0x165478[_0x201bcf(0x1f8)]+':'+(_0x165478[_0x201bcf(0x1f6)]??''):'';return _0x201bcf(0x266)+_0x165478[_0x201bcf(0x230)]+_0x201bcf(0x20e)+L(_0x165478[_0x201bcf(0x244)],_0x201bcf(0x235))+_0x201bcf(0x1ee)+L(_0x165478[_0x201bcf(0x226)],_0x201bcf(0x235))+_0x201bcf(0x210)+_0x13748e+_0x201bcf(0x240)+_0x4b18c+_0x201bcf(0x212)+L(_0x165478[_0x201bcf(0x25d)],_0x201bcf(0x235))+_0x201bcf(0x202)+_0x165478[_0x201bcf(0x261)]+'\x20duration_ms='+_0x165478['duration_ms']+'\x20lifecycle='+_0x165478[_0x201bcf(0x269)]+_0x5a3f6c;}function U(_0x381318){const _0x6f0f32=a0_0x32c978;return{'event':{'sending':'task.send.start','delivered':_0x6f0f32(0x241),'failed':_0x6f0f32(0x23b),'acked':_0x6f0f32(0x26a),'started':_0x6f0f32(0x21e),'replied':_0x6f0f32(0x209),'expired':_0x6f0f32(0x213)}[_0x381318[_0x6f0f32(0x230)]],..._0x381318};}function j(_0x40e90d){const _0x275783=a0_0x32c978;let _0x4d6f1b=_0x40e90d?.['task_id']||_0x40e90d?.[_0x275783(0x216)]||_0x40e90d?.['id'];if(_0x4d6f1b)return String(_0x4d6f1b);let _0x52bef9=_0x40e90d?.['content']?.[0x0]?.[_0x275783(0x24d)];if(typeof _0x52bef9!==_0x275783(0x203))return null;try{let _0x10e99f=JSON[_0x275783(0x222)](_0x52bef9);return _0x10e99f?.['task_id']||_0x10e99f?.[_0x275783(0x216)]||_0x10e99f?.['id']||null;}catch{return null;}}function a0_0xf4d6(_0x885ab,_0xd4566b){_0x885ab=_0x885ab-0x1ea;const _0x3b90ff=a0_0x3b90();let _0xf4d630=_0x3b90ff[_0x885ab];return _0xf4d630;}async function X(_0x2f7227,_0x5691d6){const _0x17f61f=a0_0x32c978;let _0x348b91=_0x5691d6[_0x17f61f(0x21c)]??Date[_0x17f61f(0x21c)],_0x15c8e5=_0x348b91(),_0x3217d5=(_0x3fbfb9,_0x575924,_0x2dc1e2,_0x3ab6cb)=>{const _0xdc4af7=_0x17f61f;_0x5691d6[_0xdc4af7(0x219)](O(U({'from_alias':_0x2f7227[_0xdc4af7(0x234)],'to_alias':_0x2f7227[_0xdc4af7(0x267)],'task_id':_0x575924,'parent_task_id':_0x2f7227['parentTaskId'],'network_id':_0x2f7227[_0xdc4af7(0x214)],'transport':_0x2f7227[_0xdc4af7(0x261)],'status':_0x3fbfb9,'duration_ms':_0x348b91()-_0x15c8e5,'lifecycle_tracking':_0x2f7227[_0xdc4af7(0x1ec)],..._0x2dc1e2!==void 0x0?{'error_code':_0x3ab6cb||'send_failed','error_message':N(_0x2dc1e2)}:{}})));};_0x3217d5(_0x17f61f(0x20f),null);try{let _0x54a54a=await _0x5691d6[_0x17f61f(0x262)](),_0x5c0c29=j(_0x54a54a);if(_0x5c0c29)_0x3217d5('delivered',_0x5c0c29);else{if(_0x54a54a?.['ok']===!0x1||_0x54a54a?.[_0x17f61f(0x1f3)])_0x3217d5(_0x17f61f(0x249),_0x5c0c29,_0x54a54a?.[_0x17f61f(0x1f3)]||_0x17f61f(0x1fa),'send_rejected');else _0x3217d5(_0x17f61f(0x249),null,_0x17f61f(0x228),_0x17f61f(0x253));}return _0x54a54a;}catch(_0x2af17f){throw _0x3217d5(_0x17f61f(0x249),null,_0x2af17f,_0x17f61f(0x225)),_0x2af17f;}}async function Y(_0x5c364c,_0x1fb9fa){const _0x21a005=a0_0x32c978;return X({'fromAlias':_0x5c364c[_0x21a005(0x234)],'toAlias':_0x5c364c[_0x21a005(0x265)],'parentTaskId':_0x5c364c[_0x21a005(0x258)]||null,'networkId':_0x5c364c[_0x21a005(0x214)]||null,'transport':_0x21a005(0x1ff),'lifecycleTracking':_0x21a005(0x1f2)},_0x1fb9fa);}class $ extends a0_0x39481c{[a0_0x32c978(0x239)];[a0_0x32c978(0x265)];[a0_0x32c978(0x248)];[a0_0x32c978(0x237)];[a0_0x32c978(0x255)];[a0_0x32c978(0x251)];['reconnectDelay'];[a0_0x32c978(0x25e)];['sseAbort'];['running']=!0x1;constructor(_0x15d5ea){const _0x50b757=a0_0x32c978;super();if(this['url']=_0x15d5ea[_0x50b757(0x239)]['replace'](/\/$/,''),this['alias']=_0x15d5ea['alias'],this['token']=_0x15d5ea[_0x50b757(0x248)],this[_0x50b757(0x237)]=_0x15d5ea['agent']||_0x50b757(0x220),this[_0x50b757(0x255)]=_0x50b757(0x22a)+_0x15d5ea[_0x50b757(0x265)]+'-'+Date[_0x50b757(0x21c)]()[_0x50b757(0x208)](0x24),this['heartbeatInterval']=_0x15d5ea[_0x50b757(0x251)]??0x2bf20,this['reconnectDelay']=_0x15d5ea['reconnectDelay']??0xbb8,_0x15d5ea[_0x50b757(0x21a)]!==!0x1)this[_0x50b757(0x257)]();}[a0_0x32c978(0x219)](_0xa1014c){const _0x4fe321=a0_0x32c978;console[_0x4fe321(0x219)]('['+new Date()[_0x4fe321(0x1ea)]()[_0x4fe321(0x25f)](0x0,0x8)+_0x4fe321(0x247)+this[_0x4fe321(0x265)]+']\x20'+_0xa1014c);}async[a0_0x32c978(0x20a)](_0x32835c,_0x4e555c){const _0x4eb629=a0_0x32c978;let _0x691db2={'Content-Type':_0x4eb629(0x236),'Accept':'application/json,\x20text/event-stream'};if(this[_0x4eb629(0x248)])_0x691db2['Authorization']='Bearer\x20'+this['token'];let _0x41ebff=await(await fetch(this[_0x4eb629(0x239)]+_0x4eb629(0x1f7),{'method':_0x4eb629(0x21b),'headers':_0x691db2,'body':JSON['stringify']({'jsonrpc':_0x4eb629(0x227),'id':Date['now'](),'method':_0x4eb629(0x268),'params':{'name':_0x32835c,'arguments':_0x4e555c}})}))[_0x4eb629(0x24d)](),_0x14bfeb=_0x41ebff['match'](/data: (.+)/),_0x2469ec=_0x14bfeb?JSON[_0x4eb629(0x222)](_0x14bfeb[0x1]):JSON[_0x4eb629(0x222)](_0x41ebff),_0x5eba7b=_0x2469ec?.['result']?.[_0x4eb629(0x243)]?.[0x0]?.['text'];return _0x5eba7b?JSON[_0x4eb629(0x222)](_0x5eba7b):_0x2469ec;}async['connect'](){const _0x5045fa=a0_0x32c978;if(this['running'])return;this[_0x5045fa(0x232)]=!0x0,await this[_0x5045fa(0x230)](_0x5045fa(0x1f4)),this['log'](_0x5045fa(0x22b)),this[_0x5045fa(0x25e)]=setInterval(()=>{const _0x25bda5=_0x5045fa;this[_0x25bda5(0x230)]('idle')[_0x25bda5(0x218)](_0x2936d4=>this[_0x25bda5(0x219)]('heartbeat\x20failed:\x20'+_0x2936d4[_0x25bda5(0x1eb)]));},this[_0x5045fa(0x251)]),this['connectSSE']();}async[a0_0x32c978(0x242)](){const _0x51b5f1=a0_0x32c978;if(this[_0x51b5f1(0x232)]=!0x1,this[_0x51b5f1(0x23a)]?.[_0x51b5f1(0x23f)](),this['heartbeatTimer'])clearInterval(this[_0x51b5f1(0x25e)]);await this['status'](_0x51b5f1(0x21d))[_0x51b5f1(0x218)](()=>{}),this[_0x51b5f1(0x219)](_0x51b5f1(0x22c));}async[a0_0x32c978(0x262)](_0x3d020a,_0x33c0c5,_0xf5b1d9=a0_0x32c978(0x20c)){const _0xc6b81a=a0_0x32c978;return Y({'alias':_0x3d020a,'fromAlias':this['alias']},{'log':_0x39acbc=>console['log'](_0x39acbc),'send':()=>this[_0xc6b81a(0x20a)](_0xc6b81a(0x20b),{'alias':_0x3d020a,'task':_0x33c0c5,'priority':_0xf5b1d9,'from_session':this[_0xc6b81a(0x265)]})});}async[a0_0x32c978(0x1eb)](_0x37a333,_0x1a64ec){const _0xa60abd=a0_0x32c978;return this[_0xa60abd(0x20a)](_0xa60abd(0x23c),{'alias':_0x37a333,'message':_0x1a64ec,'from_session':this['alias']});}async[a0_0x32c978(0x205)](_0x357dcf,_0x46172d,_0x1f8858=a0_0x32c978(0x1fb)){const _0x23c4b6=a0_0x32c978;return this[_0x23c4b6(0x20a)](_0x23c4b6(0x24c),{'in_reply_to':_0x357dcf,'text':_0x46172d,'status':_0x1f8858});}async[a0_0x32c978(0x230)](_0x1a57c3,_0x117cb7){const _0x51298f=a0_0x32c978;return this['call']('report_status',{'resume_id':this[_0x51298f(0x255)],'alias':this[_0x51298f(0x265)],'status':_0x1a57c3,'server':a0_0x415061(),'hostname':a0_0x415061(),'agent':this[_0x51298f(0x237)],'project_dir':process['cwd'](),..._0x117cb7});}async[a0_0x32c978(0x259)](){const _0x5ae531=a0_0x32c978;return this[_0x5ae531(0x20a)]('get_all_status',{});}async[a0_0x32c978(0x24f)](_0x29a0ec,_0xd670dc){const _0x116d38=a0_0x32c978;return this[_0x116d38(0x20a)](_0x116d38(0x24f),{'message':_0x29a0ec,'filter_server':_0xd670dc?.['server'],'filter_status':_0xd670dc?.[_0x116d38(0x230)]});}async['connectSSE'](){const _0x290e9c=a0_0x32c978;let _0x3d339b=encodeURIComponent(this[_0x290e9c(0x265)]),_0x57828e=this['url']+_0x290e9c(0x211)+_0x3d339b,_0x26b4a7=this[_0x290e9c(0x25c)];while(this[_0x290e9c(0x232)]){try{this[_0x290e9c(0x23a)]=new AbortController();let _0x4ded89={'Accept':_0x290e9c(0x231)};if(this['token'])_0x4ded89[_0x290e9c(0x1fc)]=_0x290e9c(0x1f0)+this[_0x290e9c(0x248)];let _0x13aae7=await fetch(_0x57828e,{'headers':_0x4ded89,'signal':this['sseAbort'][_0x290e9c(0x1f9)]});if(!_0x13aae7['ok']||!_0x13aae7[_0x290e9c(0x200)]){this[_0x290e9c(0x219)]('SSE\x20failed:\x20'+_0x13aae7['status']),await this['sleep'](_0x26b4a7),_0x26b4a7=Math[_0x290e9c(0x1f5)](_0x26b4a7*1.5,0xea60);continue;}_0x26b4a7=this[_0x290e9c(0x25c)];let _0x19242c=_0x13aae7[_0x290e9c(0x200)][_0x290e9c(0x24a)](),_0x16c3ef=new TextDecoder(),_0x547310='';while(this['running']){let {done:_0x44f7c6,value:_0xce22f}=await _0x19242c[_0x290e9c(0x1ef)]();if(_0x44f7c6)break;_0x547310+=_0x16c3ef[_0x290e9c(0x224)](_0xce22f,{'stream':!0x0});let _0x32a374=_0x547310[_0x290e9c(0x22e)]('\x0a');_0x547310=_0x32a374[_0x290e9c(0x26b)]()||'';for(let _0x2b8482 of _0x32a374){if(!_0x2b8482[_0x290e9c(0x256)](_0x290e9c(0x217)))continue;try{let _0x43db63=JSON[_0x290e9c(0x222)](_0x2b8482[_0x290e9c(0x25f)](0x6));if(_0x43db63['type']===_0x290e9c(0x204)){this[_0x290e9c(0x219)](_0x290e9c(0x254)),this[_0x290e9c(0x22f)]('connected');continue;}if(_0x43db63[_0x290e9c(0x201)]===_0x290e9c(0x1fe)||_0x43db63[_0x290e9c(0x201)]==='new_message'||_0x43db63['type']==='broadcast')await this[_0x290e9c(0x250)]();}catch{}}}}catch(_0x4631ea){if(_0x4631ea['name']===_0x290e9c(0x238))break;this['emit']('error',_0x4631ea),this['log']('SSE\x20error:\x20'+_0x4631ea[_0x290e9c(0x1eb)]);}if(this['running'])this[_0x290e9c(0x22f)](_0x290e9c(0x22c)),this[_0x290e9c(0x219)](_0x290e9c(0x263)+_0x26b4a7/0x3e8+_0x290e9c(0x252)),await this[_0x290e9c(0x260)](_0x26b4a7),_0x26b4a7=Math[_0x290e9c(0x1f5)](_0x26b4a7*1.5,0xea60);}}async['processInbox'](){const _0x34a0e3=a0_0x32c978;try{let _0x2035d5=(await this[_0x34a0e3(0x20a)]('get_inbox',{'alias':this[_0x34a0e3(0x265)],'limit':0xa}))?.[_0x34a0e3(0x264)]||[];for(let _0x4fca49 of _0x2035d5)await this[_0x34a0e3(0x20a)](_0x34a0e3(0x21f),{'alias':this['alias'],'message_id':_0x4fca49['id']}),this[_0x34a0e3(0x219)]('←\x20'+_0x4fca49['from_session']+':\x20'+_0x4fca49[_0x34a0e3(0x243)][_0x34a0e3(0x25f)](0x0,0x3c)),this[_0x34a0e3(0x22f)](_0x34a0e3(0x1fd),_0x4fca49),this[_0x34a0e3(0x22f)](_0x34a0e3(0x1eb),_0x4fca49);}catch(_0x3a999b){this[_0x34a0e3(0x219)]('inbox\x20error:\x20'+_0x3a999b[_0x34a0e3(0x1eb)]);}}['sleep'](_0xf4718c){return new Promise(_0x125202=>setTimeout(_0x125202,_0xf4718c));}}var F=$;export{F as default,$ as CommHub};function a0_0x3b90(){const _0x3c02d2=['from_alias','\x20error=','3502873PzNHYu',']\x20[commhub:','token','failed','getReader','json','send_reply','text','215923RZXoAT','broadcast','processInbox','heartbeatInterval','s...','missing_task_id','SSE\x20connected','resumeId','startsWith','connect','parentTaskId','getAllStatus','replace','unknown\x20error','reconnectDelay','network_id','heartbeatTimer','slice','sleep','transport','send','SSE\x20reconnecting\x20in\x20','messages','alias','[commhub:task]\x20','toAlias','tools/call','lifecycle_tracking','task.ack','pop','toTimeString','message','lifecycleTracking','1455160dfbYhT','\x20to=','read','Bearer\x20','<pending>','not_tracked','error','idle','min','error_message','/mcp','error_code','signal','CommHub\x20rejected\x20task','completed','Authorization','task','new_task','mcp_http','body','type','\x20transport=','string','connected','reply','21fHdjFm','84852MQrsZY','toString','task.replied','call','send_task','normal','parent_task_id','\x20from=','sending','\x20task_id=','/events/','\x20network_id=','task.expired','networkId','40ZNmSRE','message_id','data:\x20','catch','log','autoConnect','POST','now','offline','task.started','ack_inbox','sdk','10fdkYWr','parse','7qjtzuh','decode','send_failed','to_alias','2.0','CommHub\x20response\x20omitted\x20task_id','24lWpKbz','sdk-','registered','disconnected','[REDACTED]','split','emit','status','text/event-stream','running','440418YAeRAY','fromAlias','<unknown>','application/json','agent','AbortError','url','sseAbort','task.send.failed','send_message','1973223lQbvzp','120836bLQsgT','abort','\x20parent_task_id=','task.send.delivered','disconnect','content'];a0_0x3b90=function(){return _0x3c02d2;};return a0_0x3b90();}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
var J=Object.freeze({anet_bin_identity:{explain:"该路径不是 anet 的包内 bin(若设过 ANET_BIN_ABS,先 unset 再重装)",command:"npm i -g @sleep2agi/agent-network"},anet_bin_source:{explain:"pin 没有可信来源。在该机器上写信任根 —— 两段都要 sudo,少一个 && 就会断链",command:`sudo install -d -m 755 /etc/anet-daemon && printf 'ANET_BIN_ABS=%s
|
|
2
|
-
' "$(command -v anet)" | sudo tee /etc/anet-daemon/path.conf`},anet_bin_permission:{explain:"该二进制 group/other 可写。一行就能修",command:'chmod go-w "$(command -v anet)"'},anet_bin_shape:{explain:"pin 的路径形态不合法(相对路径,或路径里含软链)。取它的 realpath 重新写进 path.conf",command:'readlink -f "$(command -v anet)"'},anet_bin_unknown:{explain:"daemon 没能给出类别(例如安装后二进制被换过、校验和不符)。只能看该机器的 daemon 日志取原文",command:null},anet_bin_pin_unresolved:{explain:"旧版 daemon(preview.40 及更早)只报这一个笼统原因。升级该机器的 agent-node 后才能拿到具体类别",command:null}});function G(c){if(!Number.isFinite(c)||c<0)return"?";if(c<1000)return`${Math.round(c)}ms 前`;let j=Math.floor(c/1000);if(j<60)return`${j}s 前`;let q=Math.floor(j/60);if(q<60)return`${q}m 前`;let k=Math.floor(q/60);if(k<24)return`${k}h 前`;return`${Math.floor(k/24)}d 前`}function K(c){if(typeof c==="number"&&Number.isFinite(c))return c;if(typeof c==="string"){let j=Date.parse(c);if(Number.isFinite(j))return j}return}function Q(c,j){if(typeof c.can_create_nodes!=="boolean")return{kind:"never-reported",line
|
|
3
|
-
|
|
2
|
+
' "$(command -v anet)" | sudo tee /etc/anet-daemon/path.conf`},anet_bin_permission:{explain:"该二进制 group/other 可写。一行就能修",command:'chmod go-w "$(command -v anet)"'},anet_bin_shape:{explain:"pin 的路径形态不合法(相对路径,或路径里含软链)。取它的 realpath 重新写进 path.conf",command:'readlink -f "$(command -v anet)"'},anet_bin_unknown:{explain:"daemon 没能给出类别(例如安装后二进制被换过、校验和不符)。只能看该机器的 daemon 日志取原文",command:null},anet_bin_pin_unresolved:{explain:"旧版 daemon(preview.40 及更早)只报这一个笼统原因。升级该机器的 agent-node 后才能拿到具体类别",command:null}});function G(c){if(!Number.isFinite(c)||c<0)return"?";if(c<1000)return`${Math.round(c)}ms 前`;let j=Math.floor(c/1000);if(j<60)return`${j}s 前`;let q=Math.floor(j/60);if(q<60)return`${q}m 前`;let k=Math.floor(q/60);if(k<24)return`${k}h 前`;return`${Math.floor(k/24)}d 前`}function K(c){if(typeof c==="number"&&Number.isFinite(c))return c;if(typeof c==="string"){let j=Date.parse(c);if(Number.isFinite(j))return j}return}function Q(c,j){if(typeof c.can_create_nodes!=="boolean")return{kind:"never-reported",line:`创建能力:未知 —— 这台 daemon 没报过这一格。
|
|
3
|
+
`+" (agent-node 版本早于 preview.55;升级它才能看到)"};let q=K(c.last_seen_at),k=c.create_capability_observed_ms_ago,u=q!==void 0&&typeof k==="number"&&Number.isFinite(k)?Math.max(0,j-q)+k:void 0;if(c.can_create_nodes){if(u===void 0)return{kind:"ready-age-unknown",line:`创建能力:可用
|
|
4
|
+
`+" ⚠ 不知道是什么时候测的 —— 该版本开机只算一次。重启它,或升级。"};return{kind:"ready",ageMs:u,line:`创建能力:可用(${G(u)}测)`}}let C=c.create_nodes_blocked_reason||"anet_bin_unknown",z=J[C]??{explain:`未知原因代码 ${C} —— 本 CLI 可能比那台机器的 anet 旧,升级本机 anet 或看它的 daemon 日志`,command:null},H=`完整原文只在那台机器的 daemon 日志里。
|
|
5
|
+
(它带真实机器路径,按设计不上报)`,D=[` 原因:${z.explain}`,z.command?` 修法(可整行粘贴):${z.command}`:" 修法:没有单条命令能修,见上。",` ${H}`].join(`
|
|
6
|
+
`);if(u===void 0)return{kind:"blocked-age-unknown",line:`创建能力:**不可用**(${C})
|
|
7
|
+
⚠ 不知道是什么时候测的 —— 该 daemon 版本开机只算一次,之后不再重测。
|
|
4
8
|
${D}`,fix:z};return{kind:"blocked",ageMs:u,line:`创建能力:**不可用**(${C},${G(u)}测)
|
|
5
9
|
${D}`,fix:z}}export{G as formatAge,Q as describeCapability};
|