@sleep2agi/agent-network 2.3.0-preview.126 → 2.3.0-preview.128
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_0x5ee143=a0_0x47a0;(function(_0x155587,_0x221a50){const _0x197351=a0_0x47a0,_0x4f10f5=_0x155587();while(!![]){try{const _0x3a981d=parseInt(_0x197351(0x259))/0x1*(parseInt(_0x197351(0x20e))/0x2)+parseInt(_0x197351(0x26c))/0x3*(-parseInt(_0x197351(0x1fb))/0x4)+-parseInt(_0x197351(0x1f8))/0x5+parseInt(_0x197351(0x25b))/0x6+-parseInt(_0x197351(0x227))/0x7+parseInt(_0x197351(0x244))/0x8+-parseInt(_0x197351(0x1f9))/0x9*(-parseInt(_0x197351(0x1f2))/0xa);if(_0x3a981d===_0x221a50)break;else _0x4f10f5['push'](_0x4f10f5['shift']());}catch(_0x2c6ba6){_0x4f10f5['push'](_0x4f10f5['shift']());}}}(a0_0xc4ad,0xac360));import{EventEmitter as a0_0x2ef6bd}from'events';import{hostname as a0_0x632a9e}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x3a2fa4,_0x3c519f)=>(_0x3a2fa4??_0x3c519f)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0xb6f65a){const _0x30a036=a0_0x47a0;return(_0xb6f65a instanceof Error?_0xb6f65a[_0x30a036(0x24f)]:String(_0xb6f65a??'unknown\x20error'))[_0x30a036(0x220)](K,_0x30a036(0x263))[_0x30a036(0x220)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x125a6b,_0x4b0ea6=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5ee143(0x208)){const _0x4035cf=a0_0x5ee143;if(_0x4b0ea6)return JSON['stringify'](_0x125a6b);let _0x1d0103=L(_0x125a6b[_0x4035cf(0x225)],_0x4035cf(0x1ff)),_0x1a31c0=L(_0x125a6b['task_id'],_0x4035cf(0x215)),_0x55cd7d=_0x125a6b['error_code']?_0x4035cf(0x24d)+_0x125a6b[_0x4035cf(0x22e)]+':'+(_0x125a6b['error_message']??''):'';return _0x4035cf(0x200)+_0x125a6b[_0x4035cf(0x214)]+_0x4035cf(0x262)+L(_0x125a6b[_0x4035cf(0x25e)],'<unknown>')+_0x4035cf(0x202)+L(_0x125a6b['to_alias'],_0x4035cf(0x229))+_0x4035cf(0x249)+_0x1a31c0+_0x4035cf(0x1fe)+_0x1d0103+_0x4035cf(0x232)+L(_0x125a6b[_0x4035cf(0x210)],_0x4035cf(0x229))+_0x4035cf(0x213)+_0x125a6b[_0x4035cf(0x207)]+'\x20duration_ms='+_0x125a6b[_0x4035cf(0x21e)]+_0x4035cf(0x25c)+_0x125a6b['lifecycle_tracking']+_0x55cd7d;}function U(_0x4e84d3){const _0x5b823a=a0_0x5ee143;return{'event':{'sending':_0x5b823a(0x270),'delivered':_0x5b823a(0x24b),'failed':'task.send.failed','acked':_0x5b823a(0x24e),'started':_0x5b823a(0x246),'replied':'task.replied','expired':_0x5b823a(0x22d)}[_0x4e84d3[_0x5b823a(0x214)]],..._0x4e84d3};}function a0_0xc4ad(){const _0x4fd9c4=['<missing>','[commhub:task]\x20','processInbox','\x20to=','log','from_session','delivered','ack_inbox','transport','json','message_id','alias','error','Authorization','sdk','6680nxEHRc','send_reply','network_id','task','send_task','\x20transport=','status','<pending>','match','reconnectDelay','sdk-','getReader','2.0','sleep','lifecycleTracking','task_id','duration_ms','sseAbort','replace','connected','string','url','text','parent_task_id','abort','1824767RJHjna','new_message','<unknown>','agent','connect','new_task','task.expired','error_code','catch','startsWith','missing_task_id','\x20network_id=','heartbeatInterval','SSE\x20failed:\x20','autoConnect','server','parse','fromAlias','running','get_all_status','POST','reply',']\x20[commhub:','toAlias','signal','result','disconnected','pop','heartbeatTimer','6156544cQtlwP','type','task.started','send','send_failed','\x20task_id=','split','task.send.delivered','broadcast','\x20error=','task.ack','message','/events/','Bearer\x20','SSE\x20reconnecting\x20in\x20','failed','networkId','connectSSE','parentTaskId','heartbeat\x20failed:\x20','stringify','89edcJXd','name','3279714xbLqTH','\x20lifecycle=','text/event-stream','from_alias','AbortError','registered','body','\x20from=','[REDACTED]','tools/call','not_tracked','now','emit','get_inbox','min','decode','completed','429393KErRcd','cwd','toString','content','task.send.start','20JsdIXi','application/json','token','inbox\x20error:\x20','SSE\x20connected','idle','5244030gUjPNj','3094551ewqLkl','slice','8wbGvrE','/mcp','call','\x20parent_task_id='];a0_0xc4ad=function(){return _0x4fd9c4;};return a0_0xc4ad();}function j(_0x2aead7){const _0x91b23e=a0_0x5ee143;let _0x19383a=_0x2aead7?.[_0x91b23e(0x21d)]||_0x2aead7?.['message_id']||_0x2aead7?.['id'];if(_0x19383a)return String(_0x19383a);let _0x45c8c2=_0x2aead7?.[_0x91b23e(0x26f)]?.[0x0]?.[_0x91b23e(0x224)];if(typeof _0x45c8c2!==_0x91b23e(0x222))return null;try{let _0x32ec64=JSON['parse'](_0x45c8c2);return _0x32ec64?.[_0x91b23e(0x21d)]||_0x32ec64?.[_0x91b23e(0x209)]||_0x32ec64?.['id']||null;}catch{return null;}}async function X(_0x3692fe,_0x4fca27){const _0x484551=a0_0x5ee143;let _0x1ab3ce=_0x4fca27[_0x484551(0x266)]??Date[_0x484551(0x266)],_0xe9b360=_0x1ab3ce(),_0x46b2b3=(_0xb8fd3c,_0x20eaf7,_0x715ff4,_0x198cb2)=>{const _0x1e9d7e=_0x484551;_0x4fca27['log'](O(U({'from_alias':_0x3692fe[_0x1e9d7e(0x238)],'to_alias':_0x3692fe[_0x1e9d7e(0x23e)],'task_id':_0x20eaf7,'parent_task_id':_0x3692fe['parentTaskId'],'network_id':_0x3692fe[_0x1e9d7e(0x254)],'transport':_0x3692fe[_0x1e9d7e(0x207)],'status':_0xb8fd3c,'duration_ms':_0x1ab3ce()-_0xe9b360,'lifecycle_tracking':_0x3692fe[_0x1e9d7e(0x21c)],..._0x715ff4!==void 0x0?{'error_code':_0x198cb2||_0x1e9d7e(0x248),'error_message':N(_0x715ff4)}:{}})));};_0x46b2b3('sending',null);try{let _0x1e4259=await _0x4fca27['send'](),_0x2f07f6=j(_0x1e4259);if(_0x2f07f6)_0x46b2b3(_0x484551(0x205),_0x2f07f6);else{if(_0x1e4259?.['ok']===!0x1||_0x1e4259?.[_0x484551(0x20b)])_0x46b2b3('failed',_0x2f07f6,_0x1e4259?.['error']||'CommHub\x20rejected\x20task','send_rejected');else _0x46b2b3(_0x484551(0x253),null,'CommHub\x20response\x20omitted\x20task_id',_0x484551(0x231));}return _0x1e4259;}catch(_0x35d2c4){throw _0x46b2b3(_0x484551(0x253),null,_0x35d2c4,_0x484551(0x248)),_0x35d2c4;}}async function Y(_0xaeb0b1,_0x942882){const _0x4876e5=a0_0x5ee143;return X({'fromAlias':_0xaeb0b1[_0x4876e5(0x238)],'toAlias':_0xaeb0b1[_0x4876e5(0x20a)],'parentTaskId':_0xaeb0b1[_0x4876e5(0x256)]||null,'networkId':_0xaeb0b1['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x4876e5(0x265)},_0x942882);}class $ extends a0_0x2ef6bd{[a0_0x5ee143(0x223)];['alias'];[a0_0x5ee143(0x1f4)];['agent'];['resumeId'];['heartbeatInterval'];['reconnectDelay'];['heartbeatTimer'];[a0_0x5ee143(0x21f)];['running']=!0x1;constructor(_0x27168e){const _0x5af963=a0_0x5ee143;super();if(this[_0x5af963(0x223)]=_0x27168e[_0x5af963(0x223)][_0x5af963(0x220)](/\/$/,''),this['alias']=_0x27168e[_0x5af963(0x20a)],this[_0x5af963(0x1f4)]=_0x27168e['token'],this[_0x5af963(0x22a)]=_0x27168e['agent']||_0x5af963(0x20d),this['resumeId']=_0x5af963(0x218)+_0x27168e[_0x5af963(0x20a)]+'-'+Date[_0x5af963(0x266)]()[_0x5af963(0x26e)](0x24),this[_0x5af963(0x233)]=_0x27168e[_0x5af963(0x233)]??0x2bf20,this[_0x5af963(0x217)]=_0x27168e[_0x5af963(0x217)]??0xbb8,_0x27168e[_0x5af963(0x235)]!==!0x1)this[_0x5af963(0x22b)]();}[a0_0x5ee143(0x203)](_0x27d0f0){const _0x360338=a0_0x5ee143;console['log']('['+new Date()['toTimeString']()[_0x360338(0x1fa)](0x0,0x8)+_0x360338(0x23d)+this[_0x360338(0x20a)]+']\x20'+_0x27d0f0);}async[a0_0x5ee143(0x1fd)](_0x53d031,_0x4cdb2f){const _0x3cd678=a0_0x5ee143;let _0x548c90={'Content-Type':_0x3cd678(0x1f3),'Accept':'application/json,\x20text/event-stream'};if(this[_0x3cd678(0x1f4)])_0x548c90[_0x3cd678(0x20c)]=_0x3cd678(0x251)+this['token'];let _0x157388=await(await fetch(this[_0x3cd678(0x223)]+_0x3cd678(0x1fc),{'method':_0x3cd678(0x23b),'headers':_0x548c90,'body':JSON[_0x3cd678(0x258)]({'jsonrpc':_0x3cd678(0x21a),'id':Date[_0x3cd678(0x266)](),'method':_0x3cd678(0x264),'params':{'name':_0x53d031,'arguments':_0x4cdb2f}})}))[_0x3cd678(0x224)](),_0x521fad=_0x157388[_0x3cd678(0x216)](/data: (.+)/),_0x5b26d4=_0x521fad?JSON[_0x3cd678(0x237)](_0x521fad[0x1]):JSON['parse'](_0x157388),_0x16700b=_0x5b26d4?.[_0x3cd678(0x240)]?.[_0x3cd678(0x26f)]?.[0x0]?.['text'];return _0x16700b?JSON['parse'](_0x16700b):_0x5b26d4;}async[a0_0x5ee143(0x22b)](){const _0xba34b6=a0_0x5ee143;if(this[_0xba34b6(0x239)])return;this[_0xba34b6(0x239)]=!0x0,await this['status'](_0xba34b6(0x1f7)),this[_0xba34b6(0x203)](_0xba34b6(0x260)),this[_0xba34b6(0x243)]=setInterval(()=>{const _0x5ac420=_0xba34b6;this[_0x5ac420(0x214)]('idle')[_0x5ac420(0x22f)](_0x252f58=>this['log'](_0x5ac420(0x257)+_0x252f58[_0x5ac420(0x24f)]));},this[_0xba34b6(0x233)]),this[_0xba34b6(0x255)]();}async['disconnect'](){const _0x1887ee=a0_0x5ee143;if(this['running']=!0x1,this['sseAbort']?.[_0x1887ee(0x226)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this['status']('offline')[_0x1887ee(0x22f)](()=>{}),this['log'](_0x1887ee(0x241));}async[a0_0x5ee143(0x247)](_0x532619,_0x178eca,_0x3aec7d='normal'){const _0x294d2a=a0_0x5ee143;return Y({'alias':_0x532619,'fromAlias':this[_0x294d2a(0x20a)]},{'log':_0x1ec875=>console[_0x294d2a(0x203)](_0x1ec875),'send':()=>this['call'](_0x294d2a(0x212),{'alias':_0x532619,'task':_0x178eca,'priority':_0x3aec7d,'from_session':this[_0x294d2a(0x20a)]})});}async[a0_0x5ee143(0x24f)](_0x1aa859,_0x5ac592){const _0x5755cb=a0_0x5ee143;return this['call']('send_message',{'alias':_0x1aa859,'message':_0x5ac592,'from_session':this[_0x5755cb(0x20a)]});}async[a0_0x5ee143(0x23c)](_0x413a4a,_0x561e70,_0x2ca605=a0_0x5ee143(0x26b)){const _0x419f02=a0_0x5ee143;return this[_0x419f02(0x1fd)](_0x419f02(0x20f),{'in_reply_to':_0x413a4a,'text':_0x561e70,'status':_0x2ca605});}async[a0_0x5ee143(0x214)](_0x74d946,_0x35a2a0){const _0x5f0948=a0_0x5ee143;return this['call']('report_status',{'resume_id':this['resumeId'],'alias':this['alias'],'status':_0x74d946,'server':a0_0x632a9e(),'hostname':a0_0x632a9e(),'agent':this[_0x5f0948(0x22a)],'project_dir':process[_0x5f0948(0x26d)](),..._0x35a2a0});}async['getAllStatus'](){const _0x5b8abb=a0_0x5ee143;return this[_0x5b8abb(0x1fd)](_0x5b8abb(0x23a),{});}async[a0_0x5ee143(0x24c)](_0x1a54a6,_0x4ee7d4){const _0x1be47f=a0_0x5ee143;return this[_0x1be47f(0x1fd)]('broadcast',{'message':_0x1a54a6,'filter_server':_0x4ee7d4?.[_0x1be47f(0x236)],'filter_status':_0x4ee7d4?.[_0x1be47f(0x214)]});}async[a0_0x5ee143(0x255)](){const _0xb6fbf8=a0_0x5ee143;let _0x2f48ed=encodeURIComponent(this[_0xb6fbf8(0x20a)]),_0x3aa0e8=this[_0xb6fbf8(0x223)]+_0xb6fbf8(0x250)+_0x2f48ed,_0x8942d=this['reconnectDelay'];while(this[_0xb6fbf8(0x239)]){try{this['sseAbort']=new AbortController();let _0x9e1d6f={'Accept':_0xb6fbf8(0x25d)};if(this[_0xb6fbf8(0x1f4)])_0x9e1d6f['Authorization']=_0xb6fbf8(0x251)+this[_0xb6fbf8(0x1f4)];let _0x46b31d=await fetch(_0x3aa0e8,{'headers':_0x9e1d6f,'signal':this[_0xb6fbf8(0x21f)][_0xb6fbf8(0x23f)]});if(!_0x46b31d['ok']||!_0x46b31d[_0xb6fbf8(0x261)]){this[_0xb6fbf8(0x203)](_0xb6fbf8(0x234)+_0x46b31d[_0xb6fbf8(0x214)]),await this[_0xb6fbf8(0x21b)](_0x8942d),_0x8942d=Math[_0xb6fbf8(0x269)](_0x8942d*1.5,0xea60);continue;}_0x8942d=this['reconnectDelay'];let _0x1c7610=_0x46b31d[_0xb6fbf8(0x261)][_0xb6fbf8(0x219)](),_0x227a37=new TextDecoder(),_0x4594b2='';while(this['running']){let {done:_0x257131,value:_0x5ec87b}=await _0x1c7610['read']();if(_0x257131)break;_0x4594b2+=_0x227a37[_0xb6fbf8(0x26a)](_0x5ec87b,{'stream':!0x0});let _0x122982=_0x4594b2[_0xb6fbf8(0x24a)]('\x0a');_0x4594b2=_0x122982[_0xb6fbf8(0x242)]()||'';for(let _0x153a8b of _0x122982){if(!_0x153a8b[_0xb6fbf8(0x230)]('data:\x20'))continue;try{let _0x56ecfa=JSON[_0xb6fbf8(0x237)](_0x153a8b[_0xb6fbf8(0x1fa)](0x6));if(_0x56ecfa['type']===_0xb6fbf8(0x221)){this[_0xb6fbf8(0x203)](_0xb6fbf8(0x1f6)),this['emit'](_0xb6fbf8(0x221));continue;}if(_0x56ecfa[_0xb6fbf8(0x245)]===_0xb6fbf8(0x22c)||_0x56ecfa[_0xb6fbf8(0x245)]===_0xb6fbf8(0x228)||_0x56ecfa[_0xb6fbf8(0x245)]===_0xb6fbf8(0x24c))await this[_0xb6fbf8(0x201)]();}catch{}}}}catch(_0x49f5ae){if(_0x49f5ae[_0xb6fbf8(0x25a)]===_0xb6fbf8(0x25f))break;this['emit'](_0xb6fbf8(0x20b),_0x49f5ae),this[_0xb6fbf8(0x203)]('SSE\x20error:\x20'+_0x49f5ae[_0xb6fbf8(0x24f)]);}if(this[_0xb6fbf8(0x239)])this[_0xb6fbf8(0x267)](_0xb6fbf8(0x241)),this[_0xb6fbf8(0x203)](_0xb6fbf8(0x252)+_0x8942d/0x3e8+'s...'),await this[_0xb6fbf8(0x21b)](_0x8942d),_0x8942d=Math['min'](_0x8942d*1.5,0xea60);}}async[a0_0x5ee143(0x201)](){const _0x4fa3d7=a0_0x5ee143;try{let _0x4a7c6e=(await this[_0x4fa3d7(0x1fd)](_0x4fa3d7(0x268),{'alias':this[_0x4fa3d7(0x20a)],'limit':0xa}))?.['messages']||[];for(let _0x41039d of _0x4a7c6e)await this[_0x4fa3d7(0x1fd)](_0x4fa3d7(0x206),{'alias':this[_0x4fa3d7(0x20a)],'message_id':_0x41039d['id']}),this[_0x4fa3d7(0x203)]('←\x20'+_0x41039d[_0x4fa3d7(0x204)]+':\x20'+_0x41039d[_0x4fa3d7(0x26f)][_0x4fa3d7(0x1fa)](0x0,0x3c)),this[_0x4fa3d7(0x267)](_0x4fa3d7(0x211),_0x41039d),this['emit'](_0x4fa3d7(0x24f),_0x41039d);}catch(_0x7f6e93){this[_0x4fa3d7(0x203)](_0x4fa3d7(0x1f5)+_0x7f6e93[_0x4fa3d7(0x24f)]);}}[a0_0x5ee143(0x21b)](_0x3af990){return new Promise(_0xc7c937=>setTimeout(_0xc7c937,_0x3af990));}}function a0_0x47a0(_0x455243,_0xd57dea){_0x455243=_0x455243-0x1f2;const _0xc4ad64=a0_0xc4ad();let _0x47a068=_0xc4ad64[_0x455243];return _0x47a068;}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0x4d923d=a0_0x246c;(function(_0x3f30f1,_0x1319e6){const _0x5d2b9f=a0_0x246c,_0x507146=_0x3f30f1();while(!![]){try{const _0x50408a=-parseInt(_0x5d2b9f(0x16a))/0x1+-parseInt(_0x5d2b9f(0x142))/0x2*(parseInt(_0x5d2b9f(0x164))/0x3)+parseInt(_0x5d2b9f(0x144))/0x4+-parseInt(_0x5d2b9f(0x111))/0x5*(-parseInt(_0x5d2b9f(0x15d))/0x6)+-parseInt(_0x5d2b9f(0x130))/0x7+-parseInt(_0x5d2b9f(0x13c))/0x8*(parseInt(_0x5d2b9f(0x174))/0x9)+-parseInt(_0x5d2b9f(0x158))/0xa*(-parseInt(_0x5d2b9f(0x105))/0xb);if(_0x50408a===_0x1319e6)break;else _0x507146['push'](_0x507146['shift']());}catch(_0x220aa0){_0x507146['push'](_0x507146['shift']());}}}(a0_0x45ff,0x1af1e));import{EventEmitter as a0_0x181c5d}from'events';import{hostname as a0_0x5e6f43}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x435ee7,_0x2e27b9)=>(_0x435ee7??_0x2e27b9)[a0_0x4d923d(0x123)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x46fdfc){const _0x2e0599=a0_0x4d923d;return(_0x46fdfc instanceof Error?_0x46fdfc[_0x2e0599(0x16b)]:String(_0x46fdfc??_0x2e0599(0x15b)))[_0x2e0599(0x123)](K,_0x2e0599(0x13d))[_0x2e0599(0x123)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x2e0599(0x10c)](0x0,0xf0);}function a0_0x246c(_0xc5e41a,_0x1db933){_0xc5e41a=_0xc5e41a-0x100;const _0x45ff35=a0_0x45ff();let _0x246c4b=_0x45ff35[_0xc5e41a];return _0x246c4b;}function O(_0x316eb7,_0x249ae8=process.env.ANET_TASK_TRACE_FORMAT===a0_0x4d923d(0x11c)){const _0x401911=a0_0x4d923d;if(_0x249ae8)return JSON[_0x401911(0x160)](_0x316eb7);let _0x1a3ed4=L(_0x316eb7[_0x401911(0x11e)],_0x401911(0x177)),_0x3b5e3b=L(_0x316eb7[_0x401911(0x176)],_0x401911(0x117)),_0x478849=_0x316eb7[_0x401911(0x16f)]?_0x401911(0x167)+_0x316eb7[_0x401911(0x16f)]+':'+(_0x316eb7[_0x401911(0x171)]??''):'';return'[commhub:task]\x20'+_0x316eb7['status']+_0x401911(0x124)+L(_0x316eb7[_0x401911(0x13e)],'<unknown>')+_0x401911(0x106)+L(_0x316eb7['to_alias'],_0x401911(0x15f))+_0x401911(0x141)+_0x3b5e3b+_0x401911(0x146)+_0x1a3ed4+_0x401911(0x131)+L(_0x316eb7[_0x401911(0x12a)],_0x401911(0x15f))+_0x401911(0x12d)+_0x316eb7[_0x401911(0x163)]+'\x20duration_ms='+_0x316eb7[_0x401911(0x16c)]+_0x401911(0x10a)+_0x316eb7[_0x401911(0x157)]+_0x478849;}function a0_0x45ff(){const _0x10cbaa=['emit','call','SSE\x20error:\x20','lifecycle_tracking','10CgDSes','reconnectDelay','parse','unknown\x20error','application/json,\x20text/event-stream','20136WfoVWd','registered','<unknown>','stringify','getReader','catch','transport','246SpERGh','send_failed','sleep','\x20error=','ack_inbox','running','86775ojpBAN','message','duration_ms','/mcp','cwd','error_code','Bearer\x20','error_message','tools/call',']\x20[commhub:','1134CiJMpo','now','task_id','<missing>','result','CommHub\x20response\x20omitted\x20task_id','connect','parentTaskId','disconnect','get_all_status','read','SSE\x20connected','connectSSE','from_session','disconnected','text/event-stream','4610771GQCrvN','\x20to=','task.ack','min','match','\x20lifecycle=','data:\x20','slice','log','heartbeatInterval','send','fromAlias','50hsZTPA','task.send.start','error','missing_task_id','task.started','send_task','<pending>','networkId','completed','task.replied','send_reply','json','s...','parent_task_id','sseAbort','broadcast','failed','text','replace','\x20from=','report_status','normal','connected','idle','string','network_id','CommHub\x20rejected\x20task','delivered','\x20transport=','message_id','pop','1214374sjgTKY','\x20network_id=','mcp_http','server','content','processInbox','heartbeatTimer','sdk-','alias','sending','new_message','task.expired','7608OCcypW','[REDACTED]','from_alias','lifecycleTracking','toString','\x20task_id=','1514OORlCK','agent','399208VURyZY','Authorization','\x20parent_task_id=','body','get_inbox','SSE\x20failed:\x20','type','task.send.delivered','token','signal','task','url','status','decode','resumeId','task.send.failed'];a0_0x45ff=function(){return _0x10cbaa;};return a0_0x45ff();}function U(_0x1d9460){const _0x4bafc1=a0_0x4d923d;return{'event':{'sending':_0x4bafc1(0x112),'delivered':_0x4bafc1(0x14b),'failed':_0x4bafc1(0x153),'acked':_0x4bafc1(0x107),'started':_0x4bafc1(0x115),'replied':_0x4bafc1(0x11a),'expired':_0x4bafc1(0x13b)}[_0x1d9460['status']],..._0x1d9460};}function j(_0x252aac){const _0x5ada2c=a0_0x4d923d;let _0x4263cb=_0x252aac?.[_0x5ada2c(0x176)]||_0x252aac?.[_0x5ada2c(0x12e)]||_0x252aac?.['id'];if(_0x4263cb)return String(_0x4263cb);let _0x54295c=_0x252aac?.['content']?.[0x0]?.['text'];if(typeof _0x54295c!==_0x5ada2c(0x129))return null;try{let _0x5b974e=JSON['parse'](_0x54295c);return _0x5b974e?.[_0x5ada2c(0x176)]||_0x5b974e?.[_0x5ada2c(0x12e)]||_0x5b974e?.['id']||null;}catch{return null;}}async function X(_0x21e694,_0x373bb4){const _0x476c42=a0_0x4d923d;let _0x5a0cb8=_0x373bb4[_0x476c42(0x175)]??Date['now'],_0x442c3b=_0x5a0cb8(),_0x2f4862=(_0x1d687e,_0x2ab5d5,_0x458c7a,_0x258dba)=>{const _0x2b3e72=_0x476c42;_0x373bb4[_0x2b3e72(0x10d)](O(U({'from_alias':_0x21e694[_0x2b3e72(0x110)],'to_alias':_0x21e694['toAlias'],'task_id':_0x2ab5d5,'parent_task_id':_0x21e694[_0x2b3e72(0x17b)],'network_id':_0x21e694[_0x2b3e72(0x118)],'transport':_0x21e694[_0x2b3e72(0x163)],'status':_0x1d687e,'duration_ms':_0x5a0cb8()-_0x442c3b,'lifecycle_tracking':_0x21e694[_0x2b3e72(0x13f)],..._0x458c7a!==void 0x0?{'error_code':_0x258dba||_0x2b3e72(0x165),'error_message':N(_0x458c7a)}:{}})));};_0x2f4862(_0x476c42(0x139),null);try{let _0x1f545d=await _0x373bb4[_0x476c42(0x10f)](),_0xb05e83=j(_0x1f545d);if(_0xb05e83)_0x2f4862(_0x476c42(0x12c),_0xb05e83);else{if(_0x1f545d?.['ok']===!0x1||_0x1f545d?.[_0x476c42(0x113)])_0x2f4862('failed',_0xb05e83,_0x1f545d?.[_0x476c42(0x113)]||_0x476c42(0x12b),'send_rejected');else _0x2f4862(_0x476c42(0x121),null,_0x476c42(0x179),_0x476c42(0x114));}return _0x1f545d;}catch(_0x4a70f3){throw _0x2f4862(_0x476c42(0x121),null,_0x4a70f3,'send_failed'),_0x4a70f3;}}async function Y(_0x39812d,_0xd7f1af){const _0x4e25ea=a0_0x4d923d;return X({'fromAlias':_0x39812d[_0x4e25ea(0x110)],'toAlias':_0x39812d['alias'],'parentTaskId':_0x39812d['parentTaskId']||null,'networkId':_0x39812d[_0x4e25ea(0x118)]||null,'transport':_0x4e25ea(0x132),'lifecycleTracking':'not_tracked'},_0xd7f1af);}class $ extends a0_0x181c5d{[a0_0x4d923d(0x14f)];[a0_0x4d923d(0x138)];[a0_0x4d923d(0x14c)];[a0_0x4d923d(0x143)];[a0_0x4d923d(0x152)];[a0_0x4d923d(0x10e)];[a0_0x4d923d(0x159)];[a0_0x4d923d(0x136)];[a0_0x4d923d(0x11f)];['running']=!0x1;constructor(_0x575998){const _0x2f2e1d=a0_0x4d923d;super();if(this[_0x2f2e1d(0x14f)]=_0x575998[_0x2f2e1d(0x14f)]['replace'](/\/$/,''),this[_0x2f2e1d(0x138)]=_0x575998[_0x2f2e1d(0x138)],this[_0x2f2e1d(0x14c)]=_0x575998[_0x2f2e1d(0x14c)],this['agent']=_0x575998['agent']||'sdk',this[_0x2f2e1d(0x152)]=_0x2f2e1d(0x137)+_0x575998[_0x2f2e1d(0x138)]+'-'+Date[_0x2f2e1d(0x175)]()[_0x2f2e1d(0x140)](0x24),this[_0x2f2e1d(0x10e)]=_0x575998[_0x2f2e1d(0x10e)]??0x2bf20,this[_0x2f2e1d(0x159)]=_0x575998[_0x2f2e1d(0x159)]??0xbb8,_0x575998['autoConnect']!==!0x1)this[_0x2f2e1d(0x17a)]();}[a0_0x4d923d(0x10d)](_0x666dba){const _0x49648c=a0_0x4d923d;console[_0x49648c(0x10d)]('['+new Date()['toTimeString']()[_0x49648c(0x10c)](0x0,0x8)+_0x49648c(0x173)+this[_0x49648c(0x138)]+']\x20'+_0x666dba);}async[a0_0x4d923d(0x155)](_0x90acdb,_0x44a63a){const _0x30769a=a0_0x4d923d;let _0x4de6a5={'Content-Type':'application/json','Accept':_0x30769a(0x15c)};if(this[_0x30769a(0x14c)])_0x4de6a5[_0x30769a(0x145)]=_0x30769a(0x170)+this[_0x30769a(0x14c)];let _0x4d4bbb=await(await fetch(this['url']+_0x30769a(0x16d),{'method':'POST','headers':_0x4de6a5,'body':JSON[_0x30769a(0x160)]({'jsonrpc':'2.0','id':Date['now'](),'method':_0x30769a(0x172),'params':{'name':_0x90acdb,'arguments':_0x44a63a}})}))[_0x30769a(0x122)](),_0x95d3f4=_0x4d4bbb[_0x30769a(0x109)](/data: (.+)/),_0x51e80e=_0x95d3f4?JSON['parse'](_0x95d3f4[0x1]):JSON['parse'](_0x4d4bbb),_0x52d7e9=_0x51e80e?.[_0x30769a(0x178)]?.['content']?.[0x0]?.['text'];return _0x52d7e9?JSON[_0x30769a(0x15a)](_0x52d7e9):_0x51e80e;}async[a0_0x4d923d(0x17a)](){const _0x2bd646=a0_0x4d923d;if(this['running'])return;this['running']=!0x0,await this[_0x2bd646(0x150)](_0x2bd646(0x128)),this[_0x2bd646(0x10d)](_0x2bd646(0x15e)),this[_0x2bd646(0x136)]=setInterval(()=>{const _0x1acc16=_0x2bd646;this[_0x1acc16(0x150)](_0x1acc16(0x128))[_0x1acc16(0x162)](_0x53f144=>this[_0x1acc16(0x10d)]('heartbeat\x20failed:\x20'+_0x53f144[_0x1acc16(0x16b)]));},this['heartbeatInterval']),this[_0x2bd646(0x101)]();}async[a0_0x4d923d(0x17c)](){const _0x217aa8=a0_0x4d923d;if(this[_0x217aa8(0x169)]=!0x1,this['sseAbort']?.['abort'](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0x217aa8(0x150)]('offline')[_0x217aa8(0x162)](()=>{}),this[_0x217aa8(0x10d)](_0x217aa8(0x103));}async[a0_0x4d923d(0x10f)](_0x1fe87e,_0x71af51,_0x490b60=a0_0x4d923d(0x126)){const _0x382a34=a0_0x4d923d;return Y({'alias':_0x1fe87e,'fromAlias':this[_0x382a34(0x138)]},{'log':_0x5e8454=>console[_0x382a34(0x10d)](_0x5e8454),'send':()=>this['call'](_0x382a34(0x116),{'alias':_0x1fe87e,'task':_0x71af51,'priority':_0x490b60,'from_session':this[_0x382a34(0x138)]})});}async[a0_0x4d923d(0x16b)](_0x272507,_0x426cf2){const _0x33316e=a0_0x4d923d;return this[_0x33316e(0x155)]('send_message',{'alias':_0x272507,'message':_0x426cf2,'from_session':this[_0x33316e(0x138)]});}async['reply'](_0x5f11b6,_0xda7e32,_0x2b272c=a0_0x4d923d(0x119)){const _0x2840a1=a0_0x4d923d;return this[_0x2840a1(0x155)](_0x2840a1(0x11b),{'in_reply_to':_0x5f11b6,'text':_0xda7e32,'status':_0x2b272c});}async[a0_0x4d923d(0x150)](_0x238012,_0x3d98ce){const _0x4c762e=a0_0x4d923d;return this[_0x4c762e(0x155)](_0x4c762e(0x125),{'resume_id':this[_0x4c762e(0x152)],'alias':this[_0x4c762e(0x138)],'status':_0x238012,'server':a0_0x5e6f43(),'hostname':a0_0x5e6f43(),'agent':this[_0x4c762e(0x143)],'project_dir':process[_0x4c762e(0x16e)](),..._0x3d98ce});}async['getAllStatus'](){const _0x4fe525=a0_0x4d923d;return this[_0x4fe525(0x155)](_0x4fe525(0x17d),{});}async[a0_0x4d923d(0x120)](_0x10b13b,_0x4d3c87){const _0xafb106=a0_0x4d923d;return this[_0xafb106(0x155)](_0xafb106(0x120),{'message':_0x10b13b,'filter_server':_0x4d3c87?.[_0xafb106(0x133)],'filter_status':_0x4d3c87?.[_0xafb106(0x150)]});}async[a0_0x4d923d(0x101)](){const _0x1e65e2=a0_0x4d923d;let _0x16b6f8=encodeURIComponent(this[_0x1e65e2(0x138)]),_0x3bf5f1=this[_0x1e65e2(0x14f)]+'/events/'+_0x16b6f8,_0x101429=this[_0x1e65e2(0x159)];while(this[_0x1e65e2(0x169)]){try{this[_0x1e65e2(0x11f)]=new AbortController();let _0x4dc67d={'Accept':_0x1e65e2(0x104)};if(this[_0x1e65e2(0x14c)])_0x4dc67d[_0x1e65e2(0x145)]=_0x1e65e2(0x170)+this[_0x1e65e2(0x14c)];let _0x20cf33=await fetch(_0x3bf5f1,{'headers':_0x4dc67d,'signal':this[_0x1e65e2(0x11f)][_0x1e65e2(0x14d)]});if(!_0x20cf33['ok']||!_0x20cf33[_0x1e65e2(0x147)]){this[_0x1e65e2(0x10d)](_0x1e65e2(0x149)+_0x20cf33[_0x1e65e2(0x150)]),await this['sleep'](_0x101429),_0x101429=Math[_0x1e65e2(0x108)](_0x101429*1.5,0xea60);continue;}_0x101429=this[_0x1e65e2(0x159)];let _0x28bb6c=_0x20cf33[_0x1e65e2(0x147)][_0x1e65e2(0x161)](),_0x2d26ca=new TextDecoder(),_0x5c00aa='';while(this[_0x1e65e2(0x169)]){let {done:_0x248bc9,value:_0x5d61b5}=await _0x28bb6c[_0x1e65e2(0x17e)]();if(_0x248bc9)break;_0x5c00aa+=_0x2d26ca[_0x1e65e2(0x151)](_0x5d61b5,{'stream':!0x0});let _0x2246c8=_0x5c00aa['split']('\x0a');_0x5c00aa=_0x2246c8[_0x1e65e2(0x12f)]()||'';for(let _0x3d4c16 of _0x2246c8){if(!_0x3d4c16['startsWith'](_0x1e65e2(0x10b)))continue;try{let _0x18ce3d=JSON['parse'](_0x3d4c16[_0x1e65e2(0x10c)](0x6));if(_0x18ce3d[_0x1e65e2(0x14a)]===_0x1e65e2(0x127)){this['log'](_0x1e65e2(0x100)),this[_0x1e65e2(0x154)](_0x1e65e2(0x127));continue;}if(_0x18ce3d[_0x1e65e2(0x14a)]==='new_task'||_0x18ce3d[_0x1e65e2(0x14a)]===_0x1e65e2(0x13a)||_0x18ce3d[_0x1e65e2(0x14a)]===_0x1e65e2(0x120))await this['processInbox']();}catch{}}}}catch(_0x28fc97){if(_0x28fc97['name']==='AbortError')break;this['emit'](_0x1e65e2(0x113),_0x28fc97),this[_0x1e65e2(0x10d)](_0x1e65e2(0x156)+_0x28fc97[_0x1e65e2(0x16b)]);}if(this[_0x1e65e2(0x169)])this['emit'](_0x1e65e2(0x103)),this[_0x1e65e2(0x10d)]('SSE\x20reconnecting\x20in\x20'+_0x101429/0x3e8+_0x1e65e2(0x11d)),await this[_0x1e65e2(0x166)](_0x101429),_0x101429=Math[_0x1e65e2(0x108)](_0x101429*1.5,0xea60);}}async[a0_0x4d923d(0x135)](){const _0xfffd27=a0_0x4d923d;try{let _0x4285fd=(await this[_0xfffd27(0x155)](_0xfffd27(0x148),{'alias':this[_0xfffd27(0x138)],'limit':0xa}))?.['messages']||[];for(let _0xc76a8f of _0x4285fd)await this[_0xfffd27(0x155)](_0xfffd27(0x168),{'alias':this[_0xfffd27(0x138)],'message_id':_0xc76a8f['id']}),this['log']('←\x20'+_0xc76a8f[_0xfffd27(0x102)]+':\x20'+_0xc76a8f[_0xfffd27(0x134)][_0xfffd27(0x10c)](0x0,0x3c)),this[_0xfffd27(0x154)](_0xfffd27(0x14e),_0xc76a8f),this[_0xfffd27(0x154)](_0xfffd27(0x16b),_0xc76a8f);}catch(_0x41efe0){this[_0xfffd27(0x10d)]('inbox\x20error:\x20'+_0x41efe0[_0xfffd27(0x16b)]);}}[a0_0x4d923d(0x166)](_0x86f481){return new Promise(_0x2313fb=>setTimeout(_0x2313fb,_0x86f481));}}var F=$;export{F as default,$ as CommHub};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export interface CloneArgs {
|
|
2
|
+
source: string;
|
|
3
|
+
target: string;
|
|
4
|
+
/** Raw --workdir as typed (resolved later against cwd). */
|
|
5
|
+
workdir?: string;
|
|
6
|
+
model?: string;
|
|
7
|
+
start: boolean;
|
|
8
|
+
}
|
|
9
|
+
export type CloneArgsResult = {
|
|
10
|
+
ok: true;
|
|
11
|
+
args: CloneArgs;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
error: string;
|
|
15
|
+
} | {
|
|
16
|
+
ok: false;
|
|
17
|
+
help: true;
|
|
18
|
+
};
|
|
19
|
+
export declare const NODE_CLONE_USAGE = "anet node clone <source> <new-name> [--workdir <dir>] [--model <id>] [--start]\nanet node create <new-name> --from <source> [--workdir <dir>] [--model <id>] [--start]\n\n Make a new node with the same settings as <source>, under a NEW identity.\n The clone is registered with the Hub as its own node (new node_id + token);\n it never shares the source's identity, session, login or logs.\n\n Copied: runtime, model, tools, permission flags, prompts, non-secret env,\n rules file / skills / .mcp.json (with --workdir)\n Regenerated: node_id, token, session id, co-presence sockets\n Not copied: token, sessions/threads, logs, inbox, channel bot credentials,\n codex auth.json, secret env values (key names are kept)\n\n --workdir <dir> Put the clone in another project directory (created if\n missing; path must be ASCII). Default: the source's project\n directory (the current one), sharing its rules file/skills.\n --model <id> Use a different model than the source.\n --start Start the clone right after creating it.\n\n Never copy a node directory with cp -r: the copy keeps the same node_id and\n token, so the Hub delivers every task to both processes and it runs twice.";
|
|
20
|
+
/**
|
|
21
|
+
* Parse the tokens after the verb.
|
|
22
|
+
* mode "clone": [<source>, <new>, ...flags]
|
|
23
|
+
* mode "create-from": [<new>, ...flags] with a required --from <source>
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseCloneArgs(tokens: readonly string[], mode: "clone" | "create-from"): CloneArgsResult;
|
|
26
|
+
/** Project rule: node working directories are ASCII (aliases may be Chinese, directories not). */
|
|
27
|
+
export declare function isAsciiPath(p: string): boolean;
|
|
28
|
+
export interface RefusalInput {
|
|
29
|
+
sourceId: string;
|
|
30
|
+
sourceProfile: Record<string, any>;
|
|
31
|
+
target: string;
|
|
32
|
+
sourceNodeDir: string;
|
|
33
|
+
targetNodeDir: string;
|
|
34
|
+
/** Present only when --workdir was given; absolute. */
|
|
35
|
+
explicitWorkdir?: string;
|
|
36
|
+
}
|
|
37
|
+
/** Every reason to stop before touching the Hub or the disk. null = go. */
|
|
38
|
+
export declare function cloneRefusal(i: RefusalInput): string | null;
|
|
39
|
+
export interface LedgerItem {
|
|
40
|
+
item: string;
|
|
41
|
+
note?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface CloneLedger {
|
|
44
|
+
copied: LedgerItem[];
|
|
45
|
+
regenerated: LedgerItem[];
|
|
46
|
+
skipped: LedgerItem[];
|
|
47
|
+
/** env keys whose value is a secret: the clone references `ref`, which the user must set. */
|
|
48
|
+
secrets: {
|
|
49
|
+
key: string;
|
|
50
|
+
ref: string;
|
|
51
|
+
}[];
|
|
52
|
+
}
|
|
53
|
+
export declare function emptyLedger(): CloneLedger;
|
|
54
|
+
export interface PlanInput {
|
|
55
|
+
sourceProfile: Record<string, any>;
|
|
56
|
+
target: string;
|
|
57
|
+
newNodeId: string;
|
|
58
|
+
/** Absolute project directory the clone will live in. */
|
|
59
|
+
targetWorkdir: string;
|
|
60
|
+
modelOverride?: string;
|
|
61
|
+
/** New claude-code-cli session id. */
|
|
62
|
+
newSession: () => string;
|
|
63
|
+
/** grok co-presence socket fields for the new node id (grokBuildCliCreationFields). */
|
|
64
|
+
grokFields?: (nodeId: string) => Record<string, unknown>;
|
|
65
|
+
}
|
|
66
|
+
/** Build the clone's profile (no token yet) and the ledger of what happened to each field. */
|
|
67
|
+
export declare function planCloneProfile(p: PlanInput, ledger?: CloneLedger): {
|
|
68
|
+
profile: Record<string, any>;
|
|
69
|
+
ledger: CloneLedger;
|
|
70
|
+
};
|
|
71
|
+
/** Files a codex-home may carry to the clone. Never auth.json, never .anet-copresence.env. */
|
|
72
|
+
export declare const CODEX_HOME_COPY: readonly ["config.toml", "AGENTS.md", "version.json"];
|
|
73
|
+
export declare const CODEX_HOME_COPY_DIRS: readonly ["skills"];
|
|
74
|
+
/** Workdir-level settings copied only when the clone gets its own --workdir. */
|
|
75
|
+
export declare const WORKDIR_COPY_FILES: readonly ["CLAUDE.md", "AGENTS.md"];
|
|
76
|
+
export declare const WORKDIR_COPY_DIRS: readonly [".claude/skills", ".agents/skills", ".grok/skills", ".opencode/skill", ".opencode/skills"];
|
|
77
|
+
/** Recursive copy that never follows symlinks and never copies credential-looking files. Returns files copied. */
|
|
78
|
+
export declare function copyTreeSafe(from: string, to: string, skipped: LedgerItem[], label: string): number;
|
|
79
|
+
/** Strip values from env/headers of every MCP server; drop the commhub entry (regenerated at start). */
|
|
80
|
+
export declare function sanitizeMcpJson(raw: string): {
|
|
81
|
+
text: string;
|
|
82
|
+
blanked: string[];
|
|
83
|
+
};
|
|
84
|
+
export interface CopyFilesInput {
|
|
85
|
+
sourceNodeDir: string;
|
|
86
|
+
targetNodeDir: string;
|
|
87
|
+
sourceWorkdir: string;
|
|
88
|
+
targetWorkdir: string;
|
|
89
|
+
}
|
|
90
|
+
/** Copy the whitelisted on-disk settings. The target node dir must already exist. */
|
|
91
|
+
export declare function copyCloneFiles(i: CopyFilesInput, ledger: CloneLedger): void;
|
|
92
|
+
export interface RunCloneInput {
|
|
93
|
+
sourceId: string;
|
|
94
|
+
/** Raw source config.json (as stored, before normalisation). */
|
|
95
|
+
sourceProfile: Record<string, any>;
|
|
96
|
+
target: string;
|
|
97
|
+
sourceNodeDir: string;
|
|
98
|
+
sourceWorkdir: string;
|
|
99
|
+
targetWorkdir: string;
|
|
100
|
+
/** True when the user passed --workdir. */
|
|
101
|
+
explicitWorkdir: boolean;
|
|
102
|
+
modelOverride?: string;
|
|
103
|
+
newNodeId: () => string;
|
|
104
|
+
newSession: () => string;
|
|
105
|
+
grokFields?: (nodeId: string) => Record<string, unknown>;
|
|
106
|
+
/** Hub registration — returns the new node's ntok_. Same endpoint `anet node create` uses. */
|
|
107
|
+
register: (profile: Record<string, any>) => Promise<string>;
|
|
108
|
+
/** Write config.json into targetNodeDir (the CLI passes its create writer). */
|
|
109
|
+
persist: (profile: Record<string, any>, targetNodeDir: string) => void;
|
|
110
|
+
}
|
|
111
|
+
export type RunCloneResult = {
|
|
112
|
+
ok: true;
|
|
113
|
+
profile: Record<string, any>;
|
|
114
|
+
ledger: CloneLedger;
|
|
115
|
+
targetNodeDir: string;
|
|
116
|
+
} | {
|
|
117
|
+
ok: false;
|
|
118
|
+
stage: "refused" | "register" | "write";
|
|
119
|
+
error: string;
|
|
120
|
+
};
|
|
121
|
+
export declare function runNodeClone(i: RunCloneInput): Promise<RunCloneResult>;
|
|
122
|
+
/** Test/default writer: the same config.json whitelist `anet node create` persists, mode 0600. */
|
|
123
|
+
export declare function defaultClonePersist(profile: Record<string, any>, targetNodeDir: string): void;
|
|
124
|
+
/** The summary table printed after a clone. Never prints a token or a secret value. */
|
|
125
|
+
export declare function formatCloneSummary(r: {
|
|
126
|
+
source: string;
|
|
127
|
+
target: string;
|
|
128
|
+
profile: Record<string, any>;
|
|
129
|
+
ledger: CloneLedger;
|
|
130
|
+
targetNodeDir: string;
|
|
131
|
+
sourceNodeId?: string;
|
|
132
|
+
}): string;
|
|
133
|
+
/** realpath that tolerates a missing path (resolves the nearest existing parent). */
|
|
134
|
+
export declare function realpathLoose(p: string): string;
|