@sleep2agi/agent-network 2.3.0-preview.126 → 2.3.0-preview.127
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_0x418f2e=a0_0x4ae2;(function(_0x414e82,_0x3d2a95){const _0x1fe9b1=a0_0x4ae2,_0x2ef0e9=_0x414e82();while(!![]){try{const _0x2ca167=parseInt(_0x1fe9b1(0x1d4))/0x1*(parseInt(_0x1fe9b1(0x20d))/0x2)+-parseInt(_0x1fe9b1(0x1da))/0x3+-parseInt(_0x1fe9b1(0x20b))/0x4*(-parseInt(_0x1fe9b1(0x249))/0x5)+-parseInt(_0x1fe9b1(0x1d7))/0x6*(-parseInt(_0x1fe9b1(0x1de))/0x7)+parseInt(_0x1fe9b1(0x202))/0x8+-parseInt(_0x1fe9b1(0x21d))/0x9*(-parseInt(_0x1fe9b1(0x23e))/0xa)+-parseInt(_0x1fe9b1(0x1e0))/0xb;if(_0x2ca167===_0x3d2a95)break;else _0x2ef0e9['push'](_0x2ef0e9['shift']());}catch(_0x1461ff){_0x2ef0e9['push'](_0x2ef0e9['shift']());}}}(a0_0x2db5,0xaddbc));import{EventEmitter as a0_0x3c33ac}from'events';import{hostname as a0_0x40011f}from'os';function a0_0x4ae2(_0x3930bf,_0x142388){_0x3930bf=_0x3930bf-0x1c6;const _0x2db522=a0_0x2db5();let _0x4ae244=_0x2db522[_0x3930bf];return _0x4ae244;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x23311b,_0x20dbfb)=>(_0x23311b??_0x20dbfb)[a0_0x418f2e(0x228)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x418f2e(0x1df)](0x0,0xf0);function N(_0x2d4533){const _0x56d695=a0_0x418f2e;return(_0x2d4533 instanceof Error?_0x2d4533['message']:String(_0x2d4533??_0x56d695(0x1cf)))[_0x56d695(0x228)](K,_0x56d695(0x1f3))[_0x56d695(0x228)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x56d695(0x1df)](0x0,0xf0);}function O(_0x6c81c,_0x2d75d4=process.env.ANET_TASK_TRACE_FORMAT===a0_0x418f2e(0x234)){const _0x1021a1=a0_0x418f2e;if(_0x2d75d4)return JSON[_0x1021a1(0x224)](_0x6c81c);let _0x27bc4e=L(_0x6c81c[_0x1021a1(0x1f4)],_0x1021a1(0x244)),_0x3e07be=L(_0x6c81c['task_id'],_0x1021a1(0x226)),_0x58e920=_0x6c81c[_0x1021a1(0x1f9)]?_0x1021a1(0x203)+_0x6c81c[_0x1021a1(0x1f9)]+':'+(_0x6c81c['error_message']??''):'';return _0x1021a1(0x20f)+_0x6c81c[_0x1021a1(0x200)]+_0x1021a1(0x23d)+L(_0x6c81c[_0x1021a1(0x240)],'<unknown>')+_0x1021a1(0x1c6)+L(_0x6c81c[_0x1021a1(0x1d2)],_0x1021a1(0x23b))+'\x20task_id='+_0x3e07be+_0x1021a1(0x1e3)+_0x27bc4e+_0x1021a1(0x1f7)+L(_0x6c81c[_0x1021a1(0x227)],_0x1021a1(0x23b))+_0x1021a1(0x1d8)+_0x6c81c['transport']+_0x1021a1(0x1d3)+_0x6c81c[_0x1021a1(0x1cb)]+_0x1021a1(0x1fa)+_0x6c81c[_0x1021a1(0x212)]+_0x58e920;}function U(_0x5da40b){const _0xde4c72=a0_0x418f2e;return{'event':{'sending':_0xde4c72(0x1f5),'delivered':'task.send.delivered','failed':_0xde4c72(0x23f),'acked':_0xde4c72(0x1ea),'started':_0xde4c72(0x235),'replied':_0xde4c72(0x245),'expired':_0xde4c72(0x209)}[_0x5da40b[_0xde4c72(0x200)]],..._0x5da40b};}function j(_0x3382f6){const _0x4bb307=a0_0x418f2e;let _0xa879f7=_0x3382f6?.[_0x4bb307(0x1fc)]||_0x3382f6?.[_0x4bb307(0x206)]||_0x3382f6?.['id'];if(_0xa879f7)return String(_0xa879f7);let _0x526c45=_0x3382f6?.['content']?.[0x0]?.[_0x4bb307(0x243)];if(typeof _0x526c45!==_0x4bb307(0x1cd))return null;try{let _0x38e9e5=JSON[_0x4bb307(0x1e7)](_0x526c45);return _0x38e9e5?.[_0x4bb307(0x1fc)]||_0x38e9e5?.[_0x4bb307(0x206)]||_0x38e9e5?.['id']||null;}catch{return null;}}async function X(_0x386454,_0x10c3cc){const _0x139d5f=a0_0x418f2e;let _0x2ee677=_0x10c3cc[_0x139d5f(0x1d6)]??Date[_0x139d5f(0x1d6)],_0x19f050=_0x2ee677(),_0x444823=(_0x4f91f3,_0x42141b,_0x2f6f23,_0x5d2fa8)=>{const _0x4f467f=_0x139d5f;_0x10c3cc['log'](O(U({'from_alias':_0x386454[_0x4f467f(0x1d0)],'to_alias':_0x386454[_0x4f467f(0x207)],'task_id':_0x42141b,'parent_task_id':_0x386454[_0x4f467f(0x1ec)],'network_id':_0x386454[_0x4f467f(0x21f)],'transport':_0x386454['transport'],'status':_0x4f91f3,'duration_ms':_0x2ee677()-_0x19f050,'lifecycle_tracking':_0x386454[_0x4f467f(0x1e8)],..._0x2f6f23!==void 0x0?{'error_code':_0x5d2fa8||'send_failed','error_message':N(_0x2f6f23)}:{}})));};_0x444823(_0x139d5f(0x218),null);try{let _0x5815d1=await _0x10c3cc[_0x139d5f(0x20a)](),_0x459d3f=j(_0x5815d1);if(_0x459d3f)_0x444823(_0x139d5f(0x237),_0x459d3f);else{if(_0x5815d1?.['ok']===!0x1||_0x5815d1?.['error'])_0x444823(_0x139d5f(0x213),_0x459d3f,_0x5815d1?.[_0x139d5f(0x220)]||_0x139d5f(0x246),'send_rejected');else _0x444823(_0x139d5f(0x213),null,_0x139d5f(0x236),_0x139d5f(0x1e4));}return _0x5815d1;}catch(_0x20ded1){throw _0x444823('failed',null,_0x20ded1,_0x139d5f(0x22a)),_0x20ded1;}}async function Y(_0x5961f6,_0x88fc19){const _0x461eac=a0_0x418f2e;return X({'fromAlias':_0x5961f6[_0x461eac(0x1d0)],'toAlias':_0x5961f6[_0x461eac(0x21e)],'parentTaskId':_0x5961f6['parentTaskId']||null,'networkId':_0x5961f6['networkId']||null,'transport':_0x461eac(0x22b),'lifecycleTracking':_0x461eac(0x214)},_0x88fc19);}function a0_0x2db5(){const _0x3a0e0f=['messages','text/event-stream','Bearer\x20','<unknown>','task','\x20from=','10pnJlVW','task.send.failed','from_alias','completed','reconnectDelay','text','<missing>','task.replied','CommHub\x20rejected\x20task','offline','application/json,\x20text/event-stream','65uZhAJs','broadcast','/mcp','\x20to=','split','reply','application/json','tools/call','duration_ms','registered','string','2.0','unknown\x20error','fromAlias','result','to_alias','\x20duration_ms=','661LfXISq','connected','now','25320dRyDcN','\x20transport=','from_session','2154669prVdpi','SSE\x20reconnecting\x20in\x20','new_task','SSE\x20failed:\x20','679NlqOne','slice','25173676ewFqvC','inbox\x20error:\x20','connect','\x20parent_task_id=','missing_task_id','getReader','running','parse','lifecycleTracking','body','task.ack','token','parentTaskId','decode','report_status',']\x20[commhub:','idle','agent','/events/','[REDACTED]','parent_task_id','task.send.start','sleep','\x20network_id=','connectSSE','error_code','\x20lifecycle=','match','task_id','send_message','abort','sseAbort','status','log','4078728BXYJXT','\x20error=','call','cwd','message_id','toAlias','url','task.expired','send','413032guJolz','catch','2932Tunygv','message','[commhub:task]\x20','emit','type','lifecycle_tracking','failed','not_tracked','send_task','heartbeatTimer','data:\x20','sending','disconnected','heartbeatInterval','autoConnect','content','4394718tSvqSZ','alias','networkId','error','min','SSE\x20connected','Authorization','stringify','new_message','<pending>','network_id','replace','server','send_failed','mcp_http','resumeId','sdk-','sdk','normal','toString','pop','AbortError','processInbox','json','task.started','CommHub\x20response\x20omitted\x20task_id','delivered'];a0_0x2db5=function(){return _0x3a0e0f;};return a0_0x2db5();}class $ extends a0_0x3c33ac{[a0_0x418f2e(0x208)];['alias'];['token'];[a0_0x418f2e(0x1f1)];[a0_0x418f2e(0x22c)];[a0_0x418f2e(0x21a)];['reconnectDelay'];[a0_0x418f2e(0x216)];[a0_0x418f2e(0x1ff)];[a0_0x418f2e(0x1e6)]=!0x1;constructor(_0x29c6f7){const _0x477eab=a0_0x418f2e;super();if(this['url']=_0x29c6f7[_0x477eab(0x208)][_0x477eab(0x228)](/\/$/,''),this[_0x477eab(0x21e)]=_0x29c6f7['alias'],this['token']=_0x29c6f7[_0x477eab(0x1eb)],this[_0x477eab(0x1f1)]=_0x29c6f7[_0x477eab(0x1f1)]||_0x477eab(0x22e),this[_0x477eab(0x22c)]=_0x477eab(0x22d)+_0x29c6f7[_0x477eab(0x21e)]+'-'+Date[_0x477eab(0x1d6)]()[_0x477eab(0x230)](0x24),this['heartbeatInterval']=_0x29c6f7[_0x477eab(0x21a)]??0x2bf20,this[_0x477eab(0x242)]=_0x29c6f7[_0x477eab(0x242)]??0xbb8,_0x29c6f7[_0x477eab(0x21b)]!==!0x1)this[_0x477eab(0x1e2)]();}[a0_0x418f2e(0x201)](_0x35d769){const _0xe987d=a0_0x418f2e;console[_0xe987d(0x201)]('['+new Date()['toTimeString']()['slice'](0x0,0x8)+_0xe987d(0x1ef)+this['alias']+']\x20'+_0x35d769);}async[a0_0x418f2e(0x204)](_0x140740,_0x11398c){const _0x230cb2=a0_0x418f2e;let _0x198aff={'Content-Type':_0x230cb2(0x1c9),'Accept':_0x230cb2(0x248)};if(this[_0x230cb2(0x1eb)])_0x198aff[_0x230cb2(0x223)]='Bearer\x20'+this['token'];let _0x5b37eb=await(await fetch(this[_0x230cb2(0x208)]+_0x230cb2(0x24b),{'method':'POST','headers':_0x198aff,'body':JSON[_0x230cb2(0x224)]({'jsonrpc':_0x230cb2(0x1ce),'id':Date['now'](),'method':_0x230cb2(0x1ca),'params':{'name':_0x140740,'arguments':_0x11398c}})}))['text'](),_0x2f2793=_0x5b37eb[_0x230cb2(0x1fb)](/data: (.+)/),_0x3a401=_0x2f2793?JSON[_0x230cb2(0x1e7)](_0x2f2793[0x1]):JSON[_0x230cb2(0x1e7)](_0x5b37eb),_0x1ebb0a=_0x3a401?.[_0x230cb2(0x1d1)]?.[_0x230cb2(0x21c)]?.[0x0]?.[_0x230cb2(0x243)];return _0x1ebb0a?JSON[_0x230cb2(0x1e7)](_0x1ebb0a):_0x3a401;}async[a0_0x418f2e(0x1e2)](){const _0x3f30ec=a0_0x418f2e;if(this[_0x3f30ec(0x1e6)])return;this['running']=!0x0,await this['status'](_0x3f30ec(0x1f0)),this[_0x3f30ec(0x201)](_0x3f30ec(0x1cc)),this['heartbeatTimer']=setInterval(()=>{const _0x58c58c=_0x3f30ec;this[_0x58c58c(0x200)](_0x58c58c(0x1f0))[_0x58c58c(0x20c)](_0x13c4a7=>this[_0x58c58c(0x201)]('heartbeat\x20failed:\x20'+_0x13c4a7[_0x58c58c(0x20e)]));},this[_0x3f30ec(0x21a)]),this[_0x3f30ec(0x1f8)]();}async['disconnect'](){const _0x1cf5d2=a0_0x418f2e;if(this[_0x1cf5d2(0x1e6)]=!0x1,this[_0x1cf5d2(0x1ff)]?.[_0x1cf5d2(0x1fe)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this['status'](_0x1cf5d2(0x247))[_0x1cf5d2(0x20c)](()=>{}),this[_0x1cf5d2(0x201)]('disconnected');}async['send'](_0x25c32e,_0x21d1e5,_0x5a7e01=a0_0x418f2e(0x22f)){const _0x2da13b=a0_0x418f2e;return Y({'alias':_0x25c32e,'fromAlias':this[_0x2da13b(0x21e)]},{'log':_0x43f255=>console[_0x2da13b(0x201)](_0x43f255),'send':()=>this[_0x2da13b(0x204)](_0x2da13b(0x215),{'alias':_0x25c32e,'task':_0x21d1e5,'priority':_0x5a7e01,'from_session':this['alias']})});}async['message'](_0x2f067f,_0x4b4378){const _0x1b6958=a0_0x418f2e;return this[_0x1b6958(0x204)](_0x1b6958(0x1fd),{'alias':_0x2f067f,'message':_0x4b4378,'from_session':this[_0x1b6958(0x21e)]});}async[a0_0x418f2e(0x1c8)](_0x9cdd79,_0x4f727d,_0x2d6efc=a0_0x418f2e(0x241)){const _0x29e572=a0_0x418f2e;return this[_0x29e572(0x204)]('send_reply',{'in_reply_to':_0x9cdd79,'text':_0x4f727d,'status':_0x2d6efc});}async[a0_0x418f2e(0x200)](_0x146675,_0x236f0b){const _0x555737=a0_0x418f2e;return this['call'](_0x555737(0x1ee),{'resume_id':this[_0x555737(0x22c)],'alias':this['alias'],'status':_0x146675,'server':a0_0x40011f(),'hostname':a0_0x40011f(),'agent':this[_0x555737(0x1f1)],'project_dir':process[_0x555737(0x205)](),..._0x236f0b});}async['getAllStatus'](){const _0x32b6e7=a0_0x418f2e;return this[_0x32b6e7(0x204)]('get_all_status',{});}async[a0_0x418f2e(0x24a)](_0x1d2d68,_0x43f8fd){const _0x5174d8=a0_0x418f2e;return this[_0x5174d8(0x204)](_0x5174d8(0x24a),{'message':_0x1d2d68,'filter_server':_0x43f8fd?.[_0x5174d8(0x229)],'filter_status':_0x43f8fd?.[_0x5174d8(0x200)]});}async[a0_0x418f2e(0x1f8)](){const _0x57c991=a0_0x418f2e;let _0x25fb9e=encodeURIComponent(this['alias']),_0x38dc04=this[_0x57c991(0x208)]+_0x57c991(0x1f2)+_0x25fb9e,_0x451857=this[_0x57c991(0x242)];while(this[_0x57c991(0x1e6)]){try{this[_0x57c991(0x1ff)]=new AbortController();let _0x5cbed6={'Accept':_0x57c991(0x239)};if(this[_0x57c991(0x1eb)])_0x5cbed6['Authorization']=_0x57c991(0x23a)+this['token'];let _0x3101d8=await fetch(_0x38dc04,{'headers':_0x5cbed6,'signal':this[_0x57c991(0x1ff)]['signal']});if(!_0x3101d8['ok']||!_0x3101d8['body']){this['log'](_0x57c991(0x1dd)+_0x3101d8[_0x57c991(0x200)]),await this['sleep'](_0x451857),_0x451857=Math[_0x57c991(0x221)](_0x451857*1.5,0xea60);continue;}_0x451857=this['reconnectDelay'];let _0x1702c4=_0x3101d8[_0x57c991(0x1e9)][_0x57c991(0x1e5)](),_0x4e4ec8=new TextDecoder(),_0x24a903='';while(this[_0x57c991(0x1e6)]){let {done:_0x1838ba,value:_0x362820}=await _0x1702c4['read']();if(_0x1838ba)break;_0x24a903+=_0x4e4ec8[_0x57c991(0x1ed)](_0x362820,{'stream':!0x0});let _0x440a29=_0x24a903[_0x57c991(0x1c7)]('\x0a');_0x24a903=_0x440a29[_0x57c991(0x231)]()||'';for(let _0x2973ff of _0x440a29){if(!_0x2973ff['startsWith'](_0x57c991(0x217)))continue;try{let _0x236248=JSON[_0x57c991(0x1e7)](_0x2973ff['slice'](0x6));if(_0x236248[_0x57c991(0x211)]==='connected'){this['log'](_0x57c991(0x222)),this[_0x57c991(0x210)](_0x57c991(0x1d5));continue;}if(_0x236248[_0x57c991(0x211)]===_0x57c991(0x1dc)||_0x236248['type']===_0x57c991(0x225)||_0x236248[_0x57c991(0x211)]===_0x57c991(0x24a))await this[_0x57c991(0x233)]();}catch{}}}}catch(_0x4ee57e){if(_0x4ee57e['name']===_0x57c991(0x232))break;this[_0x57c991(0x210)](_0x57c991(0x220),_0x4ee57e),this[_0x57c991(0x201)]('SSE\x20error:\x20'+_0x4ee57e[_0x57c991(0x20e)]);}if(this['running'])this[_0x57c991(0x210)](_0x57c991(0x219)),this['log'](_0x57c991(0x1db)+_0x451857/0x3e8+'s...'),await this[_0x57c991(0x1f6)](_0x451857),_0x451857=Math['min'](_0x451857*1.5,0xea60);}}async[a0_0x418f2e(0x233)](){const _0x144cdb=a0_0x418f2e;try{let _0x12793b=(await this['call']('get_inbox',{'alias':this[_0x144cdb(0x21e)],'limit':0xa}))?.[_0x144cdb(0x238)]||[];for(let _0x486355 of _0x12793b)await this[_0x144cdb(0x204)]('ack_inbox',{'alias':this[_0x144cdb(0x21e)],'message_id':_0x486355['id']}),this[_0x144cdb(0x201)]('←\x20'+_0x486355[_0x144cdb(0x1d9)]+':\x20'+_0x486355[_0x144cdb(0x21c)][_0x144cdb(0x1df)](0x0,0x3c)),this['emit'](_0x144cdb(0x23c),_0x486355),this[_0x144cdb(0x210)](_0x144cdb(0x20e),_0x486355);}catch(_0x329f2e){this[_0x144cdb(0x201)](_0x144cdb(0x1e1)+_0x329f2e[_0x144cdb(0x20e)]);}}[a0_0x418f2e(0x1f6)](_0x47d15c){return new Promise(_0x3c0ed9=>setTimeout(_0x3c0ed9,_0x47d15c));}}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;
|