@sleep2agi/agent-network 2.3.0-preview.113 → 2.3.0-preview.115
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_0x239bda=a0_0x16e4;(function(_0x45c6fd,_0x5aa123){const _0x8b3aa8=a0_0x16e4,_0x12265c=_0x45c6fd();while(!![]){try{const _0x1a5e97=-parseInt(_0x8b3aa8(0x13c))/0x1*(parseInt(_0x8b3aa8(0x115))/0x2)+-parseInt(_0x8b3aa8(0x171))/0x3*(-parseInt(_0x8b3aa8(0x111))/0x4)+-parseInt(_0x8b3aa8(0x145))/0x5+-parseInt(_0x8b3aa8(0x112))/0x6+parseInt(_0x8b3aa8(0x146))/0x7*(parseInt(_0x8b3aa8(0x119))/0x8)+parseInt(_0x8b3aa8(0x15b))/0x9+parseInt(_0x8b3aa8(0x149))/0xa*(parseInt(_0x8b3aa8(0x137))/0xb);if(_0x1a5e97===_0x5aa123)break;else _0x12265c['push'](_0x12265c['shift']());}catch(_0x3ab8c0){_0x12265c['push'](_0x12265c['shift']());}}}(a0_0x3052,0x326e6));import{EventEmitter as a0_0x7b4736}from'events';import{hostname as a0_0x4ef828}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x3de8ff,_0x5435f2)=>(_0x3de8ff??_0x5435f2)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x239bda(0xfc)](0x0,0xf0);function a0_0x3052(){const _0x45df98=['url','/events/','cwd','read','token','CommHub\x20rejected\x20task','idle','ack_inbox','sleep','getReader','message_id','POST','call','55048MTOSeJ','1172124VHWnKp','networkId','task.send.start','94mYDFOZ','task','<missing>','heartbeatInterval','1567344vQVZMu','to_alias','task.send.failed','error_code','data:\x20','toTimeString','application/json','message','from_alias','server','connect','SSE\x20error:\x20','result','new_task','completed','offline','<pending>','text/event-stream','2.0','inbox\x20error:\x20','reply',']\x20[commhub:','\x20duration_ms=','log','processInbox','json','get_all_status','Authorization','status','heartbeat\x20failed:\x20','197285DkKdqP','getAllStatus','task_id','parentTaskId','sending','7085KBqfYz','lifecycle_tracking','reconnectDelay','report_status','toString','\x20lifecycle=','min','get_inbox','registered','484165wfOVMS','7DTXgzj','send','now','90tYoVRP','\x20transport=','parent_task_id','\x20task_id=','send_message','match','SSE\x20connected','name','network_id','stringify','alias','task.started','<unknown>','connected','type','fromAlias','\x20network_id=','heartbeatTimer','677853iSefrj','emit','resumeId','send_reply','[commhub:task]\x20','missing_task_id','disconnected','send_task','CommHub\x20response\x20omitted\x20task_id','sseAbort','failed','agent','text','broadcast','parse','transport','send_failed','connectSSE','string','delivered','catch','sdk-','87SJDmOZ','task.ack','task.expired','signal','autoConnect','normal','body','unknown\x20error','SSE\x20failed:\x20','lifecycleTracking','pop','running','SSE\x20reconnecting\x20in\x20','replace','error','split','slice','send_rejected','\x20parent_task_id=','startsWith','/mcp','not_tracked','AbortError','content'];a0_0x3052=function(){return _0x45df98;};return a0_0x3052();}function N(_0x3d0162){const _0xde428=a0_0x239bda;return(_0x3d0162 instanceof Error?_0x3d0162[_0xde428(0x120)]:String(_0x3d0162??_0xde428(0x178)))[_0xde428(0x17e)](K,'[REDACTED]')['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0xde428(0xfc)](0x0,0xf0);}function O(_0x4e2dfd,_0x90493c=process.env.ANET_TASK_TRACE_FORMAT===a0_0x239bda(0x132)){const _0x2a0e38=a0_0x239bda;if(_0x90493c)return JSON[_0x2a0e38(0x152)](_0x4e2dfd);let _0x2c0efa=L(_0x4e2dfd[_0x2a0e38(0x14b)],_0x2a0e38(0x117)),_0x55734c=L(_0x4e2dfd[_0x2a0e38(0x139)],_0x2a0e38(0x129)),_0x4a0c84=_0x4e2dfd[_0x2a0e38(0x11c)]?'\x20error='+_0x4e2dfd['error_code']+':'+(_0x4e2dfd['error_message']??''):'';return _0x2a0e38(0x15f)+_0x4e2dfd[_0x2a0e38(0x135)]+'\x20from='+L(_0x4e2dfd[_0x2a0e38(0x121)],'<unknown>')+'\x20to='+L(_0x4e2dfd[_0x2a0e38(0x11a)],_0x2a0e38(0x155))+_0x2a0e38(0x14c)+_0x55734c+_0x2a0e38(0xfe)+_0x2c0efa+_0x2a0e38(0x159)+L(_0x4e2dfd[_0x2a0e38(0x151)],_0x2a0e38(0x155))+_0x2a0e38(0x14a)+_0x4e2dfd[_0x2a0e38(0x16a)]+_0x2a0e38(0x12f)+_0x4e2dfd['duration_ms']+_0x2a0e38(0x141)+_0x4e2dfd[_0x2a0e38(0x13d)]+_0x4a0c84;}function U(_0x466689){const _0x48eb34=a0_0x239bda;return{'event':{'sending':_0x48eb34(0x114),'delivered':'task.send.delivered','failed':_0x48eb34(0x11b),'acked':_0x48eb34(0x172),'started':_0x48eb34(0x154),'replied':'task.replied','expired':_0x48eb34(0x173)}[_0x466689[_0x48eb34(0x135)]],..._0x466689};}function j(_0x4ab035){const _0x199902=a0_0x239bda;let _0x20c4a8=_0x4ab035?.['task_id']||_0x4ab035?.[_0x199902(0x10e)]||_0x4ab035?.['id'];if(_0x20c4a8)return String(_0x20c4a8);let _0x38a3c9=_0x4ab035?.[_0x199902(0x103)]?.[0x0]?.[_0x199902(0x167)];if(typeof _0x38a3c9!==_0x199902(0x16d))return null;try{let _0x4f69b5=JSON[_0x199902(0x169)](_0x38a3c9);return _0x4f69b5?.['task_id']||_0x4f69b5?.['message_id']||_0x4f69b5?.['id']||null;}catch{return null;}}async function X(_0x8d53c7,_0x5a1e5e){const _0xee2fd5=a0_0x239bda;let _0x32f459=_0x5a1e5e['now']??Date[_0xee2fd5(0x148)],_0x25f692=_0x32f459(),_0x497563=(_0x55bf1c,_0x41dc1e,_0x440ab2,_0x1127bc)=>{const _0x516b04=_0xee2fd5;_0x5a1e5e[_0x516b04(0x130)](O(U({'from_alias':_0x8d53c7[_0x516b04(0x158)],'to_alias':_0x8d53c7['toAlias'],'task_id':_0x41dc1e,'parent_task_id':_0x8d53c7['parentTaskId'],'network_id':_0x8d53c7[_0x516b04(0x113)],'transport':_0x8d53c7[_0x516b04(0x16a)],'status':_0x55bf1c,'duration_ms':_0x32f459()-_0x25f692,'lifecycle_tracking':_0x8d53c7[_0x516b04(0x17a)],..._0x440ab2!==void 0x0?{'error_code':_0x1127bc||_0x516b04(0x16b),'error_message':N(_0x440ab2)}:{}})));};_0x497563(_0xee2fd5(0x13b),null);try{let _0x463e57=await _0x5a1e5e[_0xee2fd5(0x147)](),_0x1d8625=j(_0x463e57);if(_0x1d8625)_0x497563(_0xee2fd5(0x16e),_0x1d8625);else{if(_0x463e57?.['ok']===!0x1||_0x463e57?.[_0xee2fd5(0x17f)])_0x497563(_0xee2fd5(0x165),_0x1d8625,_0x463e57?.[_0xee2fd5(0x17f)]||_0xee2fd5(0x109),_0xee2fd5(0xfd));else _0x497563(_0xee2fd5(0x165),null,_0xee2fd5(0x163),_0xee2fd5(0x160));}return _0x463e57;}catch(_0x2d3d54){throw _0x497563('failed',null,_0x2d3d54,'send_failed'),_0x2d3d54;}}async function Y(_0x73558e,_0x4d6e81){const _0x41bb59=a0_0x239bda;return X({'fromAlias':_0x73558e[_0x41bb59(0x158)],'toAlias':_0x73558e[_0x41bb59(0x153)],'parentTaskId':_0x73558e[_0x41bb59(0x13a)]||null,'networkId':_0x73558e[_0x41bb59(0x113)]||null,'transport':'mcp_http','lifecycleTracking':_0x41bb59(0x101)},_0x4d6e81);}class $ extends a0_0x7b4736{['url'];[a0_0x239bda(0x153)];['token'];[a0_0x239bda(0x166)];[a0_0x239bda(0x15d)];['heartbeatInterval'];[a0_0x239bda(0x13e)];[a0_0x239bda(0x15a)];[a0_0x239bda(0x164)];[a0_0x239bda(0x17c)]=!0x1;constructor(_0x223920){const _0x1a6d58=a0_0x239bda;super();if(this[_0x1a6d58(0x104)]=_0x223920[_0x1a6d58(0x104)][_0x1a6d58(0x17e)](/\/$/,''),this['alias']=_0x223920[_0x1a6d58(0x153)],this[_0x1a6d58(0x108)]=_0x223920[_0x1a6d58(0x108)],this[_0x1a6d58(0x166)]=_0x223920[_0x1a6d58(0x166)]||'sdk',this['resumeId']=_0x1a6d58(0x170)+_0x223920[_0x1a6d58(0x153)]+'-'+Date[_0x1a6d58(0x148)]()[_0x1a6d58(0x140)](0x24),this[_0x1a6d58(0x118)]=_0x223920['heartbeatInterval']??0x2bf20,this[_0x1a6d58(0x13e)]=_0x223920[_0x1a6d58(0x13e)]??0xbb8,_0x223920[_0x1a6d58(0x175)]!==!0x1)this[_0x1a6d58(0x123)]();}['log'](_0x447ae9){const _0x3bbdc0=a0_0x239bda;console[_0x3bbdc0(0x130)]('['+new Date()[_0x3bbdc0(0x11e)]()[_0x3bbdc0(0xfc)](0x0,0x8)+_0x3bbdc0(0x12e)+this[_0x3bbdc0(0x153)]+']\x20'+_0x447ae9);}async[a0_0x239bda(0x110)](_0x13fba5,_0x5bda6e){const _0x54738f=a0_0x239bda;let _0x49943c={'Content-Type':_0x54738f(0x11f),'Accept':'application/json,\x20text/event-stream'};if(this[_0x54738f(0x108)])_0x49943c[_0x54738f(0x134)]='Bearer\x20'+this[_0x54738f(0x108)];let _0x578b04=await(await fetch(this['url']+_0x54738f(0x100),{'method':_0x54738f(0x10f),'headers':_0x49943c,'body':JSON[_0x54738f(0x152)]({'jsonrpc':_0x54738f(0x12b),'id':Date[_0x54738f(0x148)](),'method':'tools/call','params':{'name':_0x13fba5,'arguments':_0x5bda6e}})}))[_0x54738f(0x167)](),_0x36347d=_0x578b04[_0x54738f(0x14e)](/data: (.+)/),_0x51cd49=_0x36347d?JSON[_0x54738f(0x169)](_0x36347d[0x1]):JSON[_0x54738f(0x169)](_0x578b04),_0x1dff0c=_0x51cd49?.[_0x54738f(0x125)]?.[_0x54738f(0x103)]?.[0x0]?.[_0x54738f(0x167)];return _0x1dff0c?JSON[_0x54738f(0x169)](_0x1dff0c):_0x51cd49;}async[a0_0x239bda(0x123)](){const _0x38faf6=a0_0x239bda;if(this[_0x38faf6(0x17c)])return;this['running']=!0x0,await this[_0x38faf6(0x135)](_0x38faf6(0x10a)),this[_0x38faf6(0x130)](_0x38faf6(0x144)),this[_0x38faf6(0x15a)]=setInterval(()=>{const _0x4c3ce0=_0x38faf6;this[_0x4c3ce0(0x135)](_0x4c3ce0(0x10a))[_0x4c3ce0(0x16f)](_0x2b989f=>this[_0x4c3ce0(0x130)](_0x4c3ce0(0x136)+_0x2b989f[_0x4c3ce0(0x120)]));},this[_0x38faf6(0x118)]),this['connectSSE']();}async['disconnect'](){const _0x3715e3=a0_0x239bda;if(this[_0x3715e3(0x17c)]=!0x1,this[_0x3715e3(0x164)]?.['abort'](),this[_0x3715e3(0x15a)])clearInterval(this[_0x3715e3(0x15a)]);await this[_0x3715e3(0x135)](_0x3715e3(0x128))[_0x3715e3(0x16f)](()=>{}),this[_0x3715e3(0x130)](_0x3715e3(0x161));}async[a0_0x239bda(0x147)](_0x3d5acc,_0x23a51f,_0x5e4f88=a0_0x239bda(0x176)){const _0x20e89e=a0_0x239bda;return Y({'alias':_0x3d5acc,'fromAlias':this['alias']},{'log':_0x5f16bd=>console[_0x20e89e(0x130)](_0x5f16bd),'send':()=>this['call'](_0x20e89e(0x162),{'alias':_0x3d5acc,'task':_0x23a51f,'priority':_0x5e4f88,'from_session':this[_0x20e89e(0x153)]})});}async['message'](_0x1c678c,_0x5e0eb3){const _0x205075=a0_0x239bda;return this[_0x205075(0x110)](_0x205075(0x14d),{'alias':_0x1c678c,'message':_0x5e0eb3,'from_session':this['alias']});}async[a0_0x239bda(0x12d)](_0x25364d,_0x76b36b,_0x2bc4bd=a0_0x239bda(0x127)){const _0x1dfc3b=a0_0x239bda;return this[_0x1dfc3b(0x110)](_0x1dfc3b(0x15e),{'in_reply_to':_0x25364d,'text':_0x76b36b,'status':_0x2bc4bd});}async[a0_0x239bda(0x135)](_0x16dfd0,_0x436ca4){const _0x5e7fec=a0_0x239bda;return this[_0x5e7fec(0x110)](_0x5e7fec(0x13f),{'resume_id':this[_0x5e7fec(0x15d)],'alias':this[_0x5e7fec(0x153)],'status':_0x16dfd0,'server':a0_0x4ef828(),'hostname':a0_0x4ef828(),'agent':this[_0x5e7fec(0x166)],'project_dir':process[_0x5e7fec(0x106)](),..._0x436ca4});}async[a0_0x239bda(0x138)](){const _0x1d3671=a0_0x239bda;return this[_0x1d3671(0x110)](_0x1d3671(0x133),{});}async[a0_0x239bda(0x168)](_0x277b4a,_0x1e9600){const _0x18a234=a0_0x239bda;return this['call'](_0x18a234(0x168),{'message':_0x277b4a,'filter_server':_0x1e9600?.[_0x18a234(0x122)],'filter_status':_0x1e9600?.[_0x18a234(0x135)]});}async[a0_0x239bda(0x16c)](){const _0x56535c=a0_0x239bda;let _0x5baa9a=encodeURIComponent(this['alias']),_0x304f98=this[_0x56535c(0x104)]+_0x56535c(0x105)+_0x5baa9a,_0x1c044a=this[_0x56535c(0x13e)];while(this['running']){try{this[_0x56535c(0x164)]=new AbortController();let _0x14c5c9={'Accept':_0x56535c(0x12a)};if(this[_0x56535c(0x108)])_0x14c5c9['Authorization']='Bearer\x20'+this[_0x56535c(0x108)];let _0x28100c=await fetch(_0x304f98,{'headers':_0x14c5c9,'signal':this['sseAbort'][_0x56535c(0x174)]});if(!_0x28100c['ok']||!_0x28100c[_0x56535c(0x177)]){this[_0x56535c(0x130)](_0x56535c(0x179)+_0x28100c[_0x56535c(0x135)]),await this[_0x56535c(0x10c)](_0x1c044a),_0x1c044a=Math['min'](_0x1c044a*1.5,0xea60);continue;}_0x1c044a=this['reconnectDelay'];let _0x632a20=_0x28100c[_0x56535c(0x177)][_0x56535c(0x10d)](),_0x466b0d=new TextDecoder(),_0x360686='';while(this[_0x56535c(0x17c)]){let {done:_0x35ba17,value:_0x34f668}=await _0x632a20[_0x56535c(0x107)]();if(_0x35ba17)break;_0x360686+=_0x466b0d['decode'](_0x34f668,{'stream':!0x0});let _0x3a0874=_0x360686[_0x56535c(0xfb)]('\x0a');_0x360686=_0x3a0874[_0x56535c(0x17b)]()||'';for(let _0x4b5d49 of _0x3a0874){if(!_0x4b5d49[_0x56535c(0xff)](_0x56535c(0x11d)))continue;try{let _0x257ac4=JSON[_0x56535c(0x169)](_0x4b5d49[_0x56535c(0xfc)](0x6));if(_0x257ac4[_0x56535c(0x157)]===_0x56535c(0x156)){this[_0x56535c(0x130)](_0x56535c(0x14f)),this['emit'](_0x56535c(0x156));continue;}if(_0x257ac4[_0x56535c(0x157)]===_0x56535c(0x126)||_0x257ac4[_0x56535c(0x157)]==='new_message'||_0x257ac4['type']===_0x56535c(0x168))await this[_0x56535c(0x131)]();}catch{}}}}catch(_0x407b6c){if(_0x407b6c[_0x56535c(0x150)]===_0x56535c(0x102))break;this[_0x56535c(0x15c)]('error',_0x407b6c),this['log'](_0x56535c(0x124)+_0x407b6c[_0x56535c(0x120)]);}if(this[_0x56535c(0x17c)])this[_0x56535c(0x15c)](_0x56535c(0x161)),this[_0x56535c(0x130)](_0x56535c(0x17d)+_0x1c044a/0x3e8+'s...'),await this[_0x56535c(0x10c)](_0x1c044a),_0x1c044a=Math[_0x56535c(0x142)](_0x1c044a*1.5,0xea60);}}async[a0_0x239bda(0x131)](){const _0x1f869e=a0_0x239bda;try{let _0x3193ee=(await this['call'](_0x1f869e(0x143),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x958ebb of _0x3193ee)await this[_0x1f869e(0x110)](_0x1f869e(0x10b),{'alias':this[_0x1f869e(0x153)],'message_id':_0x958ebb['id']}),this['log']('←\x20'+_0x958ebb['from_session']+':\x20'+_0x958ebb['content'][_0x1f869e(0xfc)](0x0,0x3c)),this[_0x1f869e(0x15c)](_0x1f869e(0x116),_0x958ebb),this[_0x1f869e(0x15c)](_0x1f869e(0x120),_0x958ebb);}catch(_0x3abfaa){this[_0x1f869e(0x130)](_0x1f869e(0x12c)+_0x3abfaa['message']);}}[a0_0x239bda(0x10c)](_0xd7daf1){return new Promise(_0x585ecc=>setTimeout(_0x585ecc,_0xd7daf1));}}function a0_0x16e4(_0x53abbe,_0x1d176d){_0x53abbe=_0x53abbe-0xfb;const _0x30522e=a0_0x3052();let _0x16e416=_0x30522e[_0x53abbe];return _0x16e416;}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x12d0e6=a0_0x1e4d;(function(_0x4b1108,_0x12bfa9){const _0x9037e0=a0_0x1e4d,_0x463273=_0x4b1108();while(!![]){try{const _0x564b5d=-parseInt(_0x9037e0(0x17e))/0x1*(parseInt(_0x9037e0(0x167))/0x2)+-parseInt(_0x9037e0(0x11f))/0x3+parseInt(_0x9037e0(0x14d))/0x4+parseInt(_0x9037e0(0x146))/0x5*(parseInt(_0x9037e0(0x16e))/0x6)+-parseInt(_0x9037e0(0x166))/0x7*(-parseInt(_0x9037e0(0x125))/0x8)+parseInt(_0x9037e0(0x113))/0x9*(-parseInt(_0x9037e0(0x14c))/0xa)+parseInt(_0x9037e0(0x18c))/0xb;if(_0x564b5d===_0x12bfa9)break;else _0x463273['push'](_0x463273['shift']());}catch(_0xd18516){_0x463273['push'](_0x463273['shift']());}}}(a0_0x3faa,0x5442e));import{EventEmitter as a0_0x39d877}from'events';import{hostname as a0_0x503d6d}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x48ff48,_0x476cf8)=>(_0x48ff48??_0x476cf8)[a0_0x12d0e6(0x11b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x12d0e6(0x179)](0x0,0xf0);function N(_0x25917a){const _0x494b7e=a0_0x12d0e6;return(_0x25917a instanceof Error?_0x25917a['message']:String(_0x25917a??'unknown\x20error'))[_0x494b7e(0x11b)](K,_0x494b7e(0x189))[_0x494b7e(0x11b)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x494b7e(0x179)](0x0,0xf0);}function O(_0x5c7fed,_0x52a127=process.env.ANET_TASK_TRACE_FORMAT===a0_0x12d0e6(0x143)){const _0xac0015=a0_0x12d0e6;if(_0x52a127)return JSON[_0xac0015(0x17a)](_0x5c7fed);let _0x4ecd82=L(_0x5c7fed[_0xac0015(0x127)],_0xac0015(0x11d)),_0x4a24e2=L(_0x5c7fed[_0xac0015(0x121)],_0xac0015(0x11a)),_0x46c112=_0x5c7fed[_0xac0015(0x165)]?_0xac0015(0x160)+_0x5c7fed[_0xac0015(0x165)]+':'+(_0x5c7fed[_0xac0015(0x17d)]??''):'';return _0xac0015(0x168)+_0x5c7fed[_0xac0015(0x180)]+_0xac0015(0x18a)+L(_0x5c7fed[_0xac0015(0x144)],'<unknown>')+_0xac0015(0x141)+L(_0x5c7fed[_0xac0015(0x184)],_0xac0015(0x14a))+_0xac0015(0x131)+_0x4a24e2+_0xac0015(0x119)+_0x4ecd82+_0xac0015(0x120)+L(_0x5c7fed['network_id'],_0xac0015(0x14a))+_0xac0015(0x12d)+_0x5c7fed[_0xac0015(0x116)]+_0xac0015(0x161)+_0x5c7fed['duration_ms']+_0xac0015(0x14f)+_0x5c7fed[_0xac0015(0x169)]+_0x46c112;}function a0_0x3faa(){const _0x48836e=['offline','now','<unknown>','parse','3092210Gqmtko','208840tNBBli','inbox\x20error:\x20','\x20lifecycle=','parentTaskId','split','task.send.delivered','completed','body','POST','url','2.0','type','failed','toTimeString','text/event-stream','CommHub\x20rejected\x20task','task.started','connect','toString','\x20error=','\x20duration_ms=','send_failed','signal','call','error_code','14bgNXVc','4KlxNmI','[commhub:task]\x20','lifecycle_tracking','match','sdk','log','running','3802362awicfn','heartbeat\x20failed:\x20','sdk-','fromAlias','Authorization','report_status','/mcp','ack_inbox','connected','sleep','idle','slice','stringify','sseAbort','toAlias','error_message','317787VjtAdx',']\x20[commhub:','status','disconnected','send_task','message_id','to_alias','decode','send_reply','token','delivered','[REDACTED]','\x20from=','heartbeatInterval','9099299XozFYt','alias','send','task.ack','mcp_http','messages','SSE\x20failed:\x20','application/json','networkId','get_all_status','cwd','SSE\x20error:\x20','connectSSE','text','missing_task_id','data:\x20','18YgxONG','heartbeatTimer','send_rejected','transport','getAllStatus','s...','\x20parent_task_id=','<pending>','replace','error','<missing>','string','1212780rRmePb','\x20network_id=','task_id','result','resumeId','min','1961056tqRIIJ','abort','parent_task_id','task','from_session','processInbox','registered','Bearer\x20','\x20transport=','server','not_tracked','task.replied','\x20task_id=','broadcast','get_inbox','task.send.failed','normal','task.send.start','emit','lifecycleTracking','/events/','reconnectDelay','task.expired','autoConnect','tools/call','content','catch','read','\x20to=','message','json','from_alias','agent','5MPkawM','reply'];a0_0x3faa=function(){return _0x48836e;};return a0_0x3faa();}function U(_0x12aeab){const _0x1e7c42=a0_0x12d0e6;return{'event':{'sending':_0x1e7c42(0x136),'delivered':_0x1e7c42(0x152),'failed':_0x1e7c42(0x134),'acked':_0x1e7c42(0x18f),'started':_0x1e7c42(0x15d),'replied':_0x1e7c42(0x130),'expired':_0x1e7c42(0x13b)}[_0x12aeab['status']],..._0x12aeab};}function j(_0x5ef867){const _0x1ccbed=a0_0x12d0e6;let _0x587d3c=_0x5ef867?.[_0x1ccbed(0x121)]||_0x5ef867?.[_0x1ccbed(0x183)]||_0x5ef867?.['id'];if(_0x587d3c)return String(_0x587d3c);let _0x5df99f=_0x5ef867?.[_0x1ccbed(0x13e)]?.[0x0]?.[_0x1ccbed(0x199)];if(typeof _0x5df99f!==_0x1ccbed(0x11e))return null;try{let _0x8a062f=JSON[_0x1ccbed(0x14b)](_0x5df99f);return _0x8a062f?.['task_id']||_0x8a062f?.[_0x1ccbed(0x183)]||_0x8a062f?.['id']||null;}catch{return null;}}function a0_0x1e4d(_0x40839d,_0x21e219){_0x40839d=_0x40839d-0x113;const _0x3faaa8=a0_0x3faa();let _0x1e4dcb=_0x3faaa8[_0x40839d];return _0x1e4dcb;}async function X(_0x1dc1e7,_0x3ff9fc){const _0x24e7a7=a0_0x12d0e6;let _0x2b2c53=_0x3ff9fc[_0x24e7a7(0x149)]??Date[_0x24e7a7(0x149)],_0x289a41=_0x2b2c53(),_0x1a1da0=(_0xe2dcdc,_0x16e65d,_0x4d3c72,_0x36ec5e)=>{const _0x353f5f=_0x24e7a7;_0x3ff9fc['log'](O(U({'from_alias':_0x1dc1e7[_0x353f5f(0x171)],'to_alias':_0x1dc1e7[_0x353f5f(0x17c)],'task_id':_0x16e65d,'parent_task_id':_0x1dc1e7[_0x353f5f(0x150)],'network_id':_0x1dc1e7['networkId'],'transport':_0x1dc1e7[_0x353f5f(0x116)],'status':_0xe2dcdc,'duration_ms':_0x2b2c53()-_0x289a41,'lifecycle_tracking':_0x1dc1e7[_0x353f5f(0x138)],..._0x4d3c72!==void 0x0?{'error_code':_0x36ec5e||_0x353f5f(0x162),'error_message':N(_0x4d3c72)}:{}})));};_0x1a1da0('sending',null);try{let _0xdaee33=await _0x3ff9fc[_0x24e7a7(0x18e)](),_0x5d5bd8=j(_0xdaee33);if(_0x5d5bd8)_0x1a1da0(_0x24e7a7(0x188),_0x5d5bd8);else{if(_0xdaee33?.['ok']===!0x1||_0xdaee33?.[_0x24e7a7(0x11c)])_0x1a1da0(_0x24e7a7(0x159),_0x5d5bd8,_0xdaee33?.[_0x24e7a7(0x11c)]||_0x24e7a7(0x15c),_0x24e7a7(0x115));else _0x1a1da0(_0x24e7a7(0x159),null,'CommHub\x20response\x20omitted\x20task_id',_0x24e7a7(0x19a));}return _0xdaee33;}catch(_0x1b6986){throw _0x1a1da0(_0x24e7a7(0x159),null,_0x1b6986,'send_failed'),_0x1b6986;}}async function Y(_0x215af2,_0x536878){const _0x268b80=a0_0x12d0e6;return X({'fromAlias':_0x215af2[_0x268b80(0x171)],'toAlias':_0x215af2[_0x268b80(0x18d)],'parentTaskId':_0x215af2[_0x268b80(0x150)]||null,'networkId':_0x215af2[_0x268b80(0x194)]||null,'transport':_0x268b80(0x190),'lifecycleTracking':_0x268b80(0x12f)},_0x536878);}class $ extends a0_0x39d877{[a0_0x12d0e6(0x156)];[a0_0x12d0e6(0x18d)];[a0_0x12d0e6(0x187)];['agent'];[a0_0x12d0e6(0x123)];['heartbeatInterval'];[a0_0x12d0e6(0x13a)];[a0_0x12d0e6(0x114)];[a0_0x12d0e6(0x17b)];[a0_0x12d0e6(0x16d)]=!0x1;constructor(_0x2b3f01){const _0x5413e1=a0_0x12d0e6;super();if(this[_0x5413e1(0x156)]=_0x2b3f01[_0x5413e1(0x156)][_0x5413e1(0x11b)](/\/$/,''),this[_0x5413e1(0x18d)]=_0x2b3f01[_0x5413e1(0x18d)],this['token']=_0x2b3f01[_0x5413e1(0x187)],this['agent']=_0x2b3f01[_0x5413e1(0x145)]||_0x5413e1(0x16b),this[_0x5413e1(0x123)]=_0x5413e1(0x170)+_0x2b3f01['alias']+'-'+Date['now']()[_0x5413e1(0x15f)](0x24),this[_0x5413e1(0x18b)]=_0x2b3f01['heartbeatInterval']??0x2bf20,this['reconnectDelay']=_0x2b3f01[_0x5413e1(0x13a)]??0xbb8,_0x2b3f01[_0x5413e1(0x13c)]!==!0x1)this[_0x5413e1(0x15e)]();}[a0_0x12d0e6(0x16c)](_0x50ecfa){const _0x4495b1=a0_0x12d0e6;console[_0x4495b1(0x16c)]('['+new Date()[_0x4495b1(0x15a)]()[_0x4495b1(0x179)](0x0,0x8)+_0x4495b1(0x17f)+this[_0x4495b1(0x18d)]+']\x20'+_0x50ecfa);}async[a0_0x12d0e6(0x164)](_0x24923b,_0x39399d){const _0x225ae9=a0_0x12d0e6;let _0x1d45dd={'Content-Type':_0x225ae9(0x193),'Accept':'application/json,\x20text/event-stream'};if(this[_0x225ae9(0x187)])_0x1d45dd[_0x225ae9(0x172)]=_0x225ae9(0x12c)+this['token'];let _0x51d25a=await(await fetch(this[_0x225ae9(0x156)]+_0x225ae9(0x174),{'method':_0x225ae9(0x155),'headers':_0x1d45dd,'body':JSON['stringify']({'jsonrpc':_0x225ae9(0x157),'id':Date[_0x225ae9(0x149)](),'method':_0x225ae9(0x13d),'params':{'name':_0x24923b,'arguments':_0x39399d}})}))[_0x225ae9(0x199)](),_0x4ab2ac=_0x51d25a[_0x225ae9(0x16a)](/data: (.+)/),_0x5d9f7b=_0x4ab2ac?JSON[_0x225ae9(0x14b)](_0x4ab2ac[0x1]):JSON['parse'](_0x51d25a),_0x1b9747=_0x5d9f7b?.[_0x225ae9(0x122)]?.[_0x225ae9(0x13e)]?.[0x0]?.[_0x225ae9(0x199)];return _0x1b9747?JSON[_0x225ae9(0x14b)](_0x1b9747):_0x5d9f7b;}async['connect'](){const _0xb5738a=a0_0x12d0e6;if(this[_0xb5738a(0x16d)])return;this[_0xb5738a(0x16d)]=!0x0,await this[_0xb5738a(0x180)](_0xb5738a(0x178)),this[_0xb5738a(0x16c)](_0xb5738a(0x12b)),this['heartbeatTimer']=setInterval(()=>{const _0x478378=_0xb5738a;this['status']('idle')[_0x478378(0x13f)](_0x5d7418=>this[_0x478378(0x16c)](_0x478378(0x16f)+_0x5d7418[_0x478378(0x142)]));},this[_0xb5738a(0x18b)]),this[_0xb5738a(0x198)]();}async['disconnect'](){const _0x3bf2d3=a0_0x12d0e6;if(this['running']=!0x1,this[_0x3bf2d3(0x17b)]?.[_0x3bf2d3(0x126)](),this[_0x3bf2d3(0x114)])clearInterval(this[_0x3bf2d3(0x114)]);await this['status'](_0x3bf2d3(0x148))[_0x3bf2d3(0x13f)](()=>{}),this[_0x3bf2d3(0x16c)](_0x3bf2d3(0x181));}async['send'](_0x2cf00b,_0x1805ca,_0x40f9d3=a0_0x12d0e6(0x135)){const _0x19310b=a0_0x12d0e6;return Y({'alias':_0x2cf00b,'fromAlias':this[_0x19310b(0x18d)]},{'log':_0x2e605b=>console['log'](_0x2e605b),'send':()=>this['call'](_0x19310b(0x182),{'alias':_0x2cf00b,'task':_0x1805ca,'priority':_0x40f9d3,'from_session':this['alias']})});}async[a0_0x12d0e6(0x142)](_0x3ef5b1,_0x480069){const _0x50daa5=a0_0x12d0e6;return this[_0x50daa5(0x164)]('send_message',{'alias':_0x3ef5b1,'message':_0x480069,'from_session':this['alias']});}async[a0_0x12d0e6(0x147)](_0x301d04,_0x30ab46,_0x44466f=a0_0x12d0e6(0x153)){const _0x33504f=a0_0x12d0e6;return this[_0x33504f(0x164)](_0x33504f(0x186),{'in_reply_to':_0x301d04,'text':_0x30ab46,'status':_0x44466f});}async[a0_0x12d0e6(0x180)](_0x3a0425,_0xa44efc){const _0x14e8d0=a0_0x12d0e6;return this[_0x14e8d0(0x164)](_0x14e8d0(0x173),{'resume_id':this[_0x14e8d0(0x123)],'alias':this['alias'],'status':_0x3a0425,'server':a0_0x503d6d(),'hostname':a0_0x503d6d(),'agent':this[_0x14e8d0(0x145)],'project_dir':process[_0x14e8d0(0x196)](),..._0xa44efc});}async[a0_0x12d0e6(0x117)](){const _0x35b585=a0_0x12d0e6;return this[_0x35b585(0x164)](_0x35b585(0x195),{});}async[a0_0x12d0e6(0x132)](_0x3f4c84,_0x4176ec){const _0x540dcf=a0_0x12d0e6;return this[_0x540dcf(0x164)](_0x540dcf(0x132),{'message':_0x3f4c84,'filter_server':_0x4176ec?.[_0x540dcf(0x12e)],'filter_status':_0x4176ec?.[_0x540dcf(0x180)]});}async[a0_0x12d0e6(0x198)](){const _0x535b46=a0_0x12d0e6;let _0x511eab=encodeURIComponent(this['alias']),_0x18741a=this[_0x535b46(0x156)]+_0x535b46(0x139)+_0x511eab,_0x38ea70=this[_0x535b46(0x13a)];while(this['running']){try{this[_0x535b46(0x17b)]=new AbortController();let _0x50c431={'Accept':_0x535b46(0x15b)};if(this[_0x535b46(0x187)])_0x50c431[_0x535b46(0x172)]=_0x535b46(0x12c)+this['token'];let _0x56e14a=await fetch(_0x18741a,{'headers':_0x50c431,'signal':this[_0x535b46(0x17b)][_0x535b46(0x163)]});if(!_0x56e14a['ok']||!_0x56e14a['body']){this[_0x535b46(0x16c)](_0x535b46(0x192)+_0x56e14a[_0x535b46(0x180)]),await this[_0x535b46(0x177)](_0x38ea70),_0x38ea70=Math[_0x535b46(0x124)](_0x38ea70*1.5,0xea60);continue;}_0x38ea70=this['reconnectDelay'];let _0x449192=_0x56e14a[_0x535b46(0x154)]['getReader'](),_0x31ef91=new TextDecoder(),_0x5a3279='';while(this['running']){let {done:_0xf124b7,value:_0x40334e}=await _0x449192[_0x535b46(0x140)]();if(_0xf124b7)break;_0x5a3279+=_0x31ef91[_0x535b46(0x185)](_0x40334e,{'stream':!0x0});let _0x233597=_0x5a3279[_0x535b46(0x151)]('\x0a');_0x5a3279=_0x233597['pop']()||'';for(let _0x44dec8 of _0x233597){if(!_0x44dec8['startsWith'](_0x535b46(0x19b)))continue;try{let _0x2e385f=JSON['parse'](_0x44dec8[_0x535b46(0x179)](0x6));if(_0x2e385f['type']===_0x535b46(0x176)){this[_0x535b46(0x16c)]('SSE\x20connected'),this[_0x535b46(0x137)](_0x535b46(0x176));continue;}if(_0x2e385f['type']==='new_task'||_0x2e385f[_0x535b46(0x158)]==='new_message'||_0x2e385f[_0x535b46(0x158)]==='broadcast')await this[_0x535b46(0x12a)]();}catch{}}}}catch(_0x15247f){if(_0x15247f['name']==='AbortError')break;this['emit']('error',_0x15247f),this[_0x535b46(0x16c)](_0x535b46(0x197)+_0x15247f[_0x535b46(0x142)]);}if(this[_0x535b46(0x16d)])this[_0x535b46(0x137)](_0x535b46(0x181)),this[_0x535b46(0x16c)]('SSE\x20reconnecting\x20in\x20'+_0x38ea70/0x3e8+_0x535b46(0x118)),await this[_0x535b46(0x177)](_0x38ea70),_0x38ea70=Math[_0x535b46(0x124)](_0x38ea70*1.5,0xea60);}}async[a0_0x12d0e6(0x12a)](){const _0xa1cd4c=a0_0x12d0e6;try{let _0x26e992=(await this[_0xa1cd4c(0x164)](_0xa1cd4c(0x133),{'alias':this['alias'],'limit':0xa}))?.[_0xa1cd4c(0x191)]||[];for(let _0x307e37 of _0x26e992)await this[_0xa1cd4c(0x164)](_0xa1cd4c(0x175),{'alias':this['alias'],'message_id':_0x307e37['id']}),this[_0xa1cd4c(0x16c)]('←\x20'+_0x307e37[_0xa1cd4c(0x129)]+':\x20'+_0x307e37[_0xa1cd4c(0x13e)][_0xa1cd4c(0x179)](0x0,0x3c)),this[_0xa1cd4c(0x137)](_0xa1cd4c(0x128),_0x307e37),this[_0xa1cd4c(0x137)]('message',_0x307e37);}catch(_0x16c0aa){this[_0xa1cd4c(0x16c)](_0xa1cd4c(0x14e)+_0x16c0aa[_0xa1cd4c(0x142)]);}}[a0_0x12d0e6(0x177)](_0x184e2d){return new Promise(_0x9166a9=>setTimeout(_0x9166a9,_0x184e2d));}}var F=$;export{F as default,$ as CommHub};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export declare const NODE_FILE_READ_MAX_BYTES: number;
|
|
2
|
+
export declare const NODE_FILES_LIST_MAX = 1000;
|
|
3
|
+
export declare const NODE_FILE_PATH_MAX = 1024;
|
|
4
|
+
/** 回给 hub 的 JSON 最长这么多字符(hub 端 ack 上限相同)。 */
|
|
5
|
+
export declare const NODE_FILES_RESULT_MAX_CHARS: number;
|
|
6
|
+
export type NodeFileType = "dir" | "file" | "symlink" | "other";
|
|
7
|
+
export type HiddenReason = "secret" | "skipped";
|
|
8
|
+
export interface NodeFileEntry {
|
|
9
|
+
name: string;
|
|
10
|
+
type: NodeFileType;
|
|
11
|
+
/** 普通文件的字节数;凭据文件不给。 */
|
|
12
|
+
size?: number;
|
|
13
|
+
/** 毫秒时间戳。 */
|
|
14
|
+
mtime?: number;
|
|
15
|
+
hidden_reason?: HiddenReason;
|
|
16
|
+
/** 目录(或指向目录的软链接)不允许进入。 */
|
|
17
|
+
no_descend?: boolean;
|
|
18
|
+
/** 软链接:指向工作目录内的什么;指向外面或断链为 null(不透露目标)。 */
|
|
19
|
+
link_type?: "dir" | "file" | null;
|
|
20
|
+
}
|
|
21
|
+
export interface NodeFilesListResult {
|
|
22
|
+
path: string;
|
|
23
|
+
entries: NodeFileEntry[];
|
|
24
|
+
truncated: boolean;
|
|
25
|
+
total: number;
|
|
26
|
+
}
|
|
27
|
+
export type NodeFileReadKind = "text" | "binary" | "too_large" | "secret";
|
|
28
|
+
export interface NodeFileReadResult {
|
|
29
|
+
path: string;
|
|
30
|
+
name: string;
|
|
31
|
+
kind: NodeFileReadKind;
|
|
32
|
+
size?: number;
|
|
33
|
+
mtime?: number;
|
|
34
|
+
content?: string;
|
|
35
|
+
hidden_reason?: HiddenReason;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 纯函数:一个路径是否属于凭据。
|
|
39
|
+
* relPosix —— 相对工作目录(请求的路径,或 realpath 之后相对工作目录的路径)。
|
|
40
|
+
* rootAbs —— 工作目录自身的绝对路径(posix);只作为「祖先目录」参与判定:工作目录本身
|
|
41
|
+
* 就在 .claude/ .codex/ 之类里面时,里面的一切都算凭据;在 .anet/ 里面时
|
|
42
|
+
* config.json* 算凭据。工作目录自己的名字不参与文件名规则。
|
|
43
|
+
* 任一祖先段(含末段)是凭据目录 → secret;末段按文件名规则判。大小写不敏感(macOS 默认不分大小写)。
|
|
44
|
+
*/
|
|
45
|
+
export declare function secretReasonFor(relPosix: string, rootAbs?: string): "secret" | null;
|
|
46
|
+
/** 纯函数:这个目录能不能进入。凭据目录 → secret;node_modules → skipped;路径上任一段命中同样不行。 */
|
|
47
|
+
export declare function noDescendReasonFor(relPosix: string, rootAbs?: string): HiddenReason | null;
|
|
48
|
+
/** 客户端给的路径 → 规范化相对路径("" = 根)。不合法抛错,错误信息不回显输入。 */
|
|
49
|
+
export declare function normalizeNodeRelPath(raw: unknown): string;
|
|
50
|
+
export interface ResolvedNodePath {
|
|
51
|
+
rootReal: string;
|
|
52
|
+
real: string;
|
|
53
|
+
/** realpath 之后相对根的路径(posix)。 */
|
|
54
|
+
relReal: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 解析并收在工作目录里:realpath(根) + realpath(根/rel),后者必须在前者之内。
|
|
58
|
+
* 不存在抛 `not found`;逃出去抛 `outside the work dir`。
|
|
59
|
+
*/
|
|
60
|
+
export declare function resolveInsideWorkDir(workDir: string, rel: string): Promise<ResolvedNodePath>;
|
|
61
|
+
export declare function listNodeFiles(workDir: string, rawPath: unknown): Promise<NodeFilesListResult>;
|
|
62
|
+
export declare function readNodeFile(workDir: string, rawPath: unknown): Promise<NodeFileReadResult>;
|