@sleep2agi/agent-network 2.3.0-preview.193 → 2.3.0-preview.195
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/bin/cli.js +2 -2
- package/dist/src/client.js +1 -1
- package/dist/src/im/feishu/worker.js +97 -97
- package/dist/src/node-server.js +8 -8
- package/dist/src/opencode-agent-node-pair.d.ts +6 -6
- package/dist/src/private-state.d.ts +8 -0
- package/dist/src/windows-rename-retry.d.ts +13 -0
- package/package.json +1 -1
package/dist/src/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a0_0x5da21a=a0_0x28ff;(function(_0x205fff,_0x151844){const _0x191e7a=a0_0x28ff,_0x311e9a=_0x205fff();while(!![]){try{const _0x2c896c=-parseInt(_0x191e7a(0x1e8))/0x1+parseInt(_0x191e7a(0x205))/0x2*(-parseInt(_0x191e7a(0x23f))/0x3)+parseInt(_0x191e7a(0x216))/0x4*(parseInt(_0x191e7a(0x219))/0x5)+-parseInt(_0x191e7a(0x229))/0x6+-parseInt(_0x191e7a(0x1fe))/0x7*(-parseInt(_0x191e7a(0x21d))/0x8)+parseInt(_0x191e7a(0x207))/0x9+parseInt(_0x191e7a(0x262))/0xa*(parseInt(_0x191e7a(0x214))/0xb);if(_0x2c896c===_0x151844)break;else _0x311e9a['push'](_0x311e9a['shift']());}catch(_0x1d20cf){_0x311e9a['push'](_0x311e9a['shift']());}}}(a0_0x354e,0xae4f9));import{EventEmitter as a0_0x5c7b18}from'events';import{hostname as a0_0x5f0cad}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x480523,_0x54b39b)=>(_0x480523??_0x54b39b)[a0_0x5da21a(0x254)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x551d41){const _0xd14188=a0_0x5da21a;return(_0x551d41 instanceof Error?_0x551d41[_0xd14188(0x226)]:String(_0x551d41??'unknown\x20error'))[_0xd14188(0x254)](K,_0xd14188(0x24b))[_0xd14188(0x254)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0xd14188(0x222)](0x0,0xf0);}function a0_0x354e(){const _0x20acaa=['log','task','\x20task_id=','running','7YeCLOp','\x20error=','heartbeatTimer','\x20duration_ms=','delivered','application/json,\x20text/event-stream','content','1714iHAPpk','mcp_http','7436178aOrpDi','SSE\x20connected','reconnectDelay','parse','name','startsWith','string','task_id','getReader','tools/call','sdk','broadcast','parent_task_id','11SpsAjc','transport','8756cWehyt','cwd','task.send.delivered','825OCurHq','sending','\x20lifecycle=','pop','7568968EVWexX','disconnected','agent','error_message','from_alias','slice','sseAbort','resumeId','call','message','inbox\x20error:\x20','type','1096800VosDXX','send_message','toAlias','lifecycleTracking','status','new_message','fromAlias','task.replied','SSE\x20error:\x20','token','CommHub\x20rejected\x20task','missing_task_id','not_tracked','message_id','stringify','processInbox','[commhub:task]\x20','result','catch','Bearer\x20','Authorization','idle','1986RmWhls','/mcp','duration_ms','s...','network_id','disconnect','heartbeat\x20failed:\x20','networkId','send_task','application/json','signal','json','[REDACTED]','get_inbox','CommHub\x20response\x20omitted\x20task_id','url','failed','send_rejected','connected','connect','error_code','replace','from_session','<unknown>','alias','task.ack','now','toString','send_failed','AbortError','match','<missing>','task.send.failed','error','emit','1121390cSCWgP','/events/','send_reply','report_status','\x20from=','781576EyxgQt','messages','heartbeatInterval','\x20network_id=','reply','sleep','lifecycle_tracking','send','read','text','2.0','normal','text/event-stream','abort','to_alias','server','body','connectSSE'];a0_0x354e=function(){return _0x20acaa;};return a0_0x354e();}function O(_0x490786,_0x1a259d=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5da21a(0x24a)){const _0x4674b2=a0_0x5da21a;if(_0x1a259d)return JSON[_0x4674b2(0x237)](_0x490786);let _0x1b5bfb=L(_0x490786[_0x4674b2(0x213)],_0x4674b2(0x25e)),_0x47f44f=L(_0x490786[_0x4674b2(0x20e)],'<pending>'),_0x52decd=_0x490786[_0x4674b2(0x253)]?_0x4674b2(0x1ff)+_0x490786['error_code']+':'+(_0x490786[_0x4674b2(0x220)]??''):'';return _0x4674b2(0x239)+_0x490786[_0x4674b2(0x22d)]+_0x4674b2(0x266)+L(_0x490786[_0x4674b2(0x221)],_0x4674b2(0x256))+'\x20to='+L(_0x490786[_0x4674b2(0x1f6)],_0x4674b2(0x256))+_0x4674b2(0x1fc)+_0x47f44f+'\x20parent_task_id='+_0x1b5bfb+_0x4674b2(0x1eb)+L(_0x490786[_0x4674b2(0x243)],_0x4674b2(0x256))+'\x20transport='+_0x490786[_0x4674b2(0x215)]+_0x4674b2(0x201)+_0x490786[_0x4674b2(0x241)]+_0x4674b2(0x21b)+_0x490786[_0x4674b2(0x1ee)]+_0x52decd;}function a0_0x28ff(_0x2b7257,_0x9ce2de){_0x2b7257=_0x2b7257-0x1e8;const _0x354e57=a0_0x354e();let _0x28ff01=_0x354e57[_0x2b7257];return _0x28ff01;}function U(_0x4a57d7){const _0x468b34=a0_0x5da21a;return{'event':{'sending':'task.send.start','delivered':_0x468b34(0x218),'failed':_0x468b34(0x25f),'acked':_0x468b34(0x258),'started':'task.started','replied':_0x468b34(0x230),'expired':'task.expired'}[_0x4a57d7[_0x468b34(0x22d)]],..._0x4a57d7};}function j(_0x1b8e8d){const _0x28d34c=a0_0x5da21a;let _0x56471f=_0x1b8e8d?.[_0x28d34c(0x20e)]||_0x1b8e8d?.[_0x28d34c(0x236)]||_0x1b8e8d?.['id'];if(_0x56471f)return String(_0x56471f);let _0x350925=_0x1b8e8d?.[_0x28d34c(0x204)]?.[0x0]?.['text'];if(typeof _0x350925!==_0x28d34c(0x20d))return null;try{let _0x5d3ccd=JSON[_0x28d34c(0x20a)](_0x350925);return _0x5d3ccd?.[_0x28d34c(0x20e)]||_0x5d3ccd?.[_0x28d34c(0x236)]||_0x5d3ccd?.['id']||null;}catch{return null;}}async function X(_0x52dde0,_0x5d591d){const _0x561629=a0_0x5da21a;let _0x4c9953=_0x5d591d['now']??Date[_0x561629(0x259)],_0x234062=_0x4c9953(),_0x3d23a7=(_0x87cb96,_0x59738f,_0x26668b,_0x4f974b)=>{const _0x1c3a7c=_0x561629;_0x5d591d['log'](O(U({'from_alias':_0x52dde0[_0x1c3a7c(0x22f)],'to_alias':_0x52dde0[_0x1c3a7c(0x22b)],'task_id':_0x59738f,'parent_task_id':_0x52dde0['parentTaskId'],'network_id':_0x52dde0[_0x1c3a7c(0x246)],'transport':_0x52dde0['transport'],'status':_0x87cb96,'duration_ms':_0x4c9953()-_0x234062,'lifecycle_tracking':_0x52dde0[_0x1c3a7c(0x22c)],..._0x26668b!==void 0x0?{'error_code':_0x4f974b||'send_failed','error_message':N(_0x26668b)}:{}})));};_0x3d23a7(_0x561629(0x21a),null);try{let _0x246a0f=await _0x5d591d['send'](),_0x3065ca=j(_0x246a0f);if(_0x3065ca)_0x3d23a7(_0x561629(0x202),_0x3065ca);else{if(_0x246a0f?.['ok']===!0x1||_0x246a0f?.[_0x561629(0x260)])_0x3d23a7(_0x561629(0x24f),_0x3065ca,_0x246a0f?.[_0x561629(0x260)]||_0x561629(0x233),_0x561629(0x250));else _0x3d23a7(_0x561629(0x24f),null,_0x561629(0x24d),_0x561629(0x234));}return _0x246a0f;}catch(_0x34ed07){throw _0x3d23a7(_0x561629(0x24f),null,_0x34ed07,_0x561629(0x25b)),_0x34ed07;}}async function Y(_0x4be298,_0x1d8f63){const _0x4e8391=a0_0x5da21a;return X({'fromAlias':_0x4be298[_0x4e8391(0x22f)],'toAlias':_0x4be298['alias'],'parentTaskId':_0x4be298['parentTaskId']||null,'networkId':_0x4be298[_0x4e8391(0x246)]||null,'transport':_0x4e8391(0x206),'lifecycleTracking':_0x4e8391(0x235)},_0x1d8f63);}class $ extends a0_0x5c7b18{['url'];[a0_0x5da21a(0x257)];[a0_0x5da21a(0x232)];[a0_0x5da21a(0x21f)];[a0_0x5da21a(0x224)];['heartbeatInterval'];[a0_0x5da21a(0x209)];[a0_0x5da21a(0x200)];['sseAbort'];['running']=!0x1;constructor(_0x2fbbe3){const _0x24dad0=a0_0x5da21a;super();if(this[_0x24dad0(0x24e)]=_0x2fbbe3['url']['replace'](/\/$/,''),this[_0x24dad0(0x257)]=_0x2fbbe3[_0x24dad0(0x257)],this[_0x24dad0(0x232)]=_0x2fbbe3[_0x24dad0(0x232)],this['agent']=_0x2fbbe3[_0x24dad0(0x21f)]||_0x24dad0(0x211),this[_0x24dad0(0x224)]='sdk-'+_0x2fbbe3[_0x24dad0(0x257)]+'-'+Date['now']()[_0x24dad0(0x25a)](0x24),this[_0x24dad0(0x1ea)]=_0x2fbbe3[_0x24dad0(0x1ea)]??0x2bf20,this['reconnectDelay']=_0x2fbbe3[_0x24dad0(0x209)]??0xbb8,_0x2fbbe3['autoConnect']!==!0x1)this[_0x24dad0(0x252)]();}[a0_0x5da21a(0x1fa)](_0xd73fce){const _0x40aefe=a0_0x5da21a;console[_0x40aefe(0x1fa)]('['+new Date()['toTimeString']()[_0x40aefe(0x222)](0x0,0x8)+']\x20[commhub:'+this[_0x40aefe(0x257)]+']\x20'+_0xd73fce);}async[a0_0x5da21a(0x225)](_0x1d9a40,_0x43680f){const _0x4b4667=a0_0x5da21a;let _0x1542ab={'Content-Type':_0x4b4667(0x248),'Accept':_0x4b4667(0x203)};if(this['token'])_0x1542ab[_0x4b4667(0x23d)]=_0x4b4667(0x23c)+this[_0x4b4667(0x232)];let _0x40b31e=await(await fetch(this[_0x4b4667(0x24e)]+_0x4b4667(0x240),{'method':'POST','headers':_0x1542ab,'body':JSON[_0x4b4667(0x237)]({'jsonrpc':_0x4b4667(0x1f2),'id':Date[_0x4b4667(0x259)](),'method':_0x4b4667(0x210),'params':{'name':_0x1d9a40,'arguments':_0x43680f}})}))[_0x4b4667(0x1f1)](),_0x44a99c=_0x40b31e[_0x4b4667(0x25d)](/data: (.+)/),_0x128317=_0x44a99c?JSON['parse'](_0x44a99c[0x1]):JSON[_0x4b4667(0x20a)](_0x40b31e),_0x5a0015=_0x128317?.[_0x4b4667(0x23a)]?.[_0x4b4667(0x204)]?.[0x0]?.['text'];return _0x5a0015?JSON[_0x4b4667(0x20a)](_0x5a0015):_0x128317;}async[a0_0x5da21a(0x252)](){const _0x55979d=a0_0x5da21a;if(this[_0x55979d(0x1fd)])return;this[_0x55979d(0x1fd)]=!0x0,await this['status'](_0x55979d(0x23e)),this[_0x55979d(0x1fa)]('registered'),this[_0x55979d(0x200)]=setInterval(()=>{const _0x72269f=_0x55979d;this['status'](_0x72269f(0x23e))['catch'](_0x5189ac=>this[_0x72269f(0x1fa)](_0x72269f(0x245)+_0x5189ac['message']));},this[_0x55979d(0x1ea)]),this[_0x55979d(0x1f9)]();}async[a0_0x5da21a(0x244)](){const _0x41c52f=a0_0x5da21a;if(this[_0x41c52f(0x1fd)]=!0x1,this[_0x41c52f(0x223)]?.[_0x41c52f(0x1f5)](),this[_0x41c52f(0x200)])clearInterval(this[_0x41c52f(0x200)]);await this['status']('offline')[_0x41c52f(0x23b)](()=>{}),this[_0x41c52f(0x1fa)](_0x41c52f(0x21e));}async[a0_0x5da21a(0x1ef)](_0x4ca714,_0x3f0691,_0xae3e9e=a0_0x5da21a(0x1f3)){const _0x271a5f=a0_0x5da21a;return Y({'alias':_0x4ca714,'fromAlias':this[_0x271a5f(0x257)]},{'log':_0x135109=>console[_0x271a5f(0x1fa)](_0x135109),'send':()=>this[_0x271a5f(0x225)](_0x271a5f(0x247),{'alias':_0x4ca714,'task':_0x3f0691,'priority':_0xae3e9e,'from_session':this[_0x271a5f(0x257)]})});}async[a0_0x5da21a(0x226)](_0x5e290a,_0x533190){const _0x151279=a0_0x5da21a;return this[_0x151279(0x225)](_0x151279(0x22a),{'alias':_0x5e290a,'message':_0x533190,'from_session':this[_0x151279(0x257)]});}async[a0_0x5da21a(0x1ec)](_0x52ad50,_0x47e9b3,_0x1ff78c='completed'){const _0x4dce78=a0_0x5da21a;return this[_0x4dce78(0x225)](_0x4dce78(0x264),{'in_reply_to':_0x52ad50,'text':_0x47e9b3,'status':_0x1ff78c});}async[a0_0x5da21a(0x22d)](_0x3aa0a9,_0x48bc04){const _0xae3483=a0_0x5da21a;return this[_0xae3483(0x225)](_0xae3483(0x265),{'resume_id':this[_0xae3483(0x224)],'alias':this['alias'],'status':_0x3aa0a9,'server':a0_0x5f0cad(),'hostname':a0_0x5f0cad(),'agent':this[_0xae3483(0x21f)],'project_dir':process[_0xae3483(0x217)](),..._0x48bc04});}async['getAllStatus'](){const _0x29221d=a0_0x5da21a;return this[_0x29221d(0x225)]('get_all_status',{});}async[a0_0x5da21a(0x212)](_0xd229c3,_0x2d5326){const _0x4b6ca9=a0_0x5da21a;return this['call'](_0x4b6ca9(0x212),{'message':_0xd229c3,'filter_server':_0x2d5326?.[_0x4b6ca9(0x1f7)],'filter_status':_0x2d5326?.['status']});}async[a0_0x5da21a(0x1f9)](){const _0x44f032=a0_0x5da21a;let _0x103d0c=encodeURIComponent(this[_0x44f032(0x257)]),_0x4c6185=this[_0x44f032(0x24e)]+_0x44f032(0x263)+_0x103d0c,_0x129881=this['reconnectDelay'];while(this[_0x44f032(0x1fd)]){try{this[_0x44f032(0x223)]=new AbortController();let _0x415df0={'Accept':_0x44f032(0x1f4)};if(this[_0x44f032(0x232)])_0x415df0[_0x44f032(0x23d)]=_0x44f032(0x23c)+this[_0x44f032(0x232)];let _0x176ded=await fetch(_0x4c6185,{'headers':_0x415df0,'signal':this[_0x44f032(0x223)][_0x44f032(0x249)]});if(!_0x176ded['ok']||!_0x176ded['body']){this['log']('SSE\x20failed:\x20'+_0x176ded[_0x44f032(0x22d)]),await this[_0x44f032(0x1ed)](_0x129881),_0x129881=Math['min'](_0x129881*1.5,0xea60);continue;}_0x129881=this[_0x44f032(0x209)];let _0x50d01f=_0x176ded[_0x44f032(0x1f8)][_0x44f032(0x20f)](),_0x32c8f2=new TextDecoder(),_0x18a0eb='';while(this['running']){let {done:_0x416ae0,value:_0x209ce2}=await _0x50d01f[_0x44f032(0x1f0)]();if(_0x416ae0)break;_0x18a0eb+=_0x32c8f2['decode'](_0x209ce2,{'stream':!0x0});let _0x1cde22=_0x18a0eb['split']('\x0a');_0x18a0eb=_0x1cde22[_0x44f032(0x21c)]()||'';for(let _0x161d4a of _0x1cde22){if(!_0x161d4a[_0x44f032(0x20c)]('data:\x20'))continue;try{let _0xc057b5=JSON[_0x44f032(0x20a)](_0x161d4a[_0x44f032(0x222)](0x6));if(_0xc057b5[_0x44f032(0x228)]===_0x44f032(0x251)){this['log'](_0x44f032(0x208)),this[_0x44f032(0x261)](_0x44f032(0x251));continue;}if(_0xc057b5[_0x44f032(0x228)]==='new_task'||_0xc057b5[_0x44f032(0x228)]===_0x44f032(0x22e)||_0xc057b5[_0x44f032(0x228)]===_0x44f032(0x212))await this[_0x44f032(0x238)]();}catch{}}}}catch(_0x15c7f2){if(_0x15c7f2[_0x44f032(0x20b)]===_0x44f032(0x25c))break;this[_0x44f032(0x261)](_0x44f032(0x260),_0x15c7f2),this[_0x44f032(0x1fa)](_0x44f032(0x231)+_0x15c7f2[_0x44f032(0x226)]);}if(this['running'])this[_0x44f032(0x261)](_0x44f032(0x21e)),this[_0x44f032(0x1fa)]('SSE\x20reconnecting\x20in\x20'+_0x129881/0x3e8+_0x44f032(0x242)),await this[_0x44f032(0x1ed)](_0x129881),_0x129881=Math['min'](_0x129881*1.5,0xea60);}}async[a0_0x5da21a(0x238)](){const _0x45e6d4=a0_0x5da21a;try{let _0x23267b=(await this['call'](_0x45e6d4(0x24c),{'alias':this[_0x45e6d4(0x257)],'limit':0xa}))?.[_0x45e6d4(0x1e9)]||[];for(let _0x4b1d1d of _0x23267b)await this['call']('ack_inbox',{'alias':this[_0x45e6d4(0x257)],'message_id':_0x4b1d1d['id']}),this['log']('←\x20'+_0x4b1d1d[_0x45e6d4(0x255)]+':\x20'+_0x4b1d1d['content'][_0x45e6d4(0x222)](0x0,0x3c)),this[_0x45e6d4(0x261)](_0x45e6d4(0x1fb),_0x4b1d1d),this[_0x45e6d4(0x261)]('message',_0x4b1d1d);}catch(_0x157d44){this[_0x45e6d4(0x1fa)](_0x45e6d4(0x227)+_0x157d44['message']);}}[a0_0x5da21a(0x1ed)](_0x149672){return new Promise(_0x2b0b9f=>setTimeout(_0x2b0b9f,_0x149672));}}var F=$;export{F as default,$ as CommHub};
|
|
1
|
+
const a0_0xfef4bc=a0_0x5475;(function(_0x1a28b1,_0x3a6af2){const _0x2ec90b=a0_0x5475,_0x536a5e=_0x1a28b1();while(!![]){try{const _0x7e8920=parseInt(_0x2ec90b(0x23b))/0x1+parseInt(_0x2ec90b(0x21d))/0x2+parseInt(_0x2ec90b(0x1cc))/0x3+-parseInt(_0x2ec90b(0x1c7))/0x4*(parseInt(_0x2ec90b(0x204))/0x5)+parseInt(_0x2ec90b(0x23e))/0x6+-parseInt(_0x2ec90b(0x237))/0x7*(-parseInt(_0x2ec90b(0x1df))/0x8)+parseInt(_0x2ec90b(0x229))/0x9*(-parseInt(_0x2ec90b(0x1f3))/0xa);if(_0x7e8920===_0x3a6af2)break;else _0x536a5e['push'](_0x536a5e['shift']());}catch(_0xb4dd4c){_0x536a5e['push'](_0x536a5e['shift']());}}}(a0_0x1c3b,0x3f0e1));import{EventEmitter as a0_0xde8ec0}from'events';import{hostname as a0_0x42df73}from'os';function a0_0x5475(_0x1b4f75,_0x25df6c){_0x1b4f75=_0x1b4f75-0x1c4;const _0x1c3bf4=a0_0x1c3b();let _0x5475c5=_0x1c3bf4[_0x1b4f75];return _0x5475c5;}function a0_0x1c3b(){const _0x526ca9=['emit','task.send.delivered','task.ack','<pending>','CommHub\x20response\x20omitted\x20task_id','pop','inbox\x20error:\x20','match','send_failed','string','offline','CommHub\x20rejected\x20task','867192OmJjQJ','s...','idle','toString','sdk-','connectSSE','SSE\x20reconnecting\x20in\x20','toAlias',']\x20[commhub:','stringify','processInbox','send','1012302wbWzoI','\x20parent_task_id=','[commhub:task]\x20','send_reply','sseAbort','send_message','broadcast','connect','report_status','url','error_code','get_inbox','completed','agent','258293NitWhv','2.0','disconnected','unknown\x20error','332475wQxcHQ','get_all_status','new_message','2149638PZMcMx','parent_task_id','split','log','getReader','messages','from_session','disconnect','<unknown>','3100LGuPBD','text','server','sleep','sending','1176621awwWOv','/mcp','\x20to=','networkId','task.send.start','mcp_http','data:\x20','\x20lifecycle=','running','slice','task_id','tools/call','failed','heartbeatTimer','task.replied','heartbeatInterval','not_tracked','decode','\x20network_id=','8EtWnNK','<missing>','alias','to_alias','catch','call','type','task.expired','new_task','transport','\x20from=','Authorization','Bearer\x20','reply','missing_task_id','reconnectDelay','\x20error=','name','task','fromAlias','90LSzaSP','SSE\x20error:\x20','token','min','parentTaskId','from_alias','sdk','AbortError','\x20duration_ms=','read','now','application/json,\x20text/event-stream','send_task','network_id','/events/','message','resumeId','1825sfaBlC','getAllStatus','send_rejected','error','replace','content','startsWith','parse','lifecycleTracking','connected','task.send.failed','status','body'];a0_0x1c3b=function(){return _0x526ca9;};return a0_0x1c3b();}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x18bfe9,_0x559dfa)=>(_0x18bfe9??_0x559dfa)[a0_0xfef4bc(0x208)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0xfef4bc(0x1d5)](0x0,0xf0);function N(_0x5937c6){const _0x5ef594=a0_0xfef4bc;return(_0x5937c6 instanceof Error?_0x5937c6['message']:String(_0x5937c6??_0x5ef594(0x23a)))['replace'](K,'[REDACTED]')[_0x5ef594(0x208)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x27487d,_0x375bae=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x5d6666=a0_0xfef4bc;if(_0x375bae)return JSON[_0x5d6666(0x226)](_0x27487d);let _0x351864=L(_0x27487d[_0x5d6666(0x23f)],_0x5d6666(0x1e0)),_0x20cb3e=L(_0x27487d['task_id'],_0x5d6666(0x214)),_0x4323e8=_0x27487d[_0x5d6666(0x233)]?_0x5d6666(0x1ef)+_0x27487d[_0x5d6666(0x233)]+':'+(_0x27487d['error_message']??''):'';return _0x5d6666(0x22b)+_0x27487d['status']+_0x5d6666(0x1e9)+L(_0x27487d[_0x5d6666(0x1f8)],_0x5d6666(0x1c6))+_0x5d6666(0x1ce)+L(_0x27487d[_0x5d6666(0x1e2)],_0x5d6666(0x1c6))+'\x20task_id='+_0x20cb3e+_0x5d6666(0x22a)+_0x351864+_0x5d6666(0x1de)+L(_0x27487d[_0x5d6666(0x200)],_0x5d6666(0x1c6))+'\x20transport='+_0x27487d[_0x5d6666(0x1e8)]+_0x5d6666(0x1fb)+_0x27487d['duration_ms']+_0x5d6666(0x1d3)+_0x27487d['lifecycle_tracking']+_0x4323e8;}function U(_0x2570f5){const _0x2eddf2=a0_0xfef4bc;return{'event':{'sending':_0x2eddf2(0x1d0),'delivered':_0x2eddf2(0x212),'failed':_0x2eddf2(0x20e),'acked':_0x2eddf2(0x213),'started':'task.started','replied':_0x2eddf2(0x1da),'expired':_0x2eddf2(0x1e6)}[_0x2570f5[_0x2eddf2(0x20f)]],..._0x2570f5};}function j(_0x1b965c){const _0x5122e5=a0_0xfef4bc;let _0x423f6f=_0x1b965c?.[_0x5122e5(0x1d6)]||_0x1b965c?.['message_id']||_0x1b965c?.['id'];if(_0x423f6f)return String(_0x423f6f);let _0x3ddfcb=_0x1b965c?.['content']?.[0x0]?.[_0x5122e5(0x1c8)];if(typeof _0x3ddfcb!==_0x5122e5(0x21a))return null;try{let _0x487417=JSON[_0x5122e5(0x20b)](_0x3ddfcb);return _0x487417?.['task_id']||_0x487417?.['message_id']||_0x487417?.['id']||null;}catch{return null;}}async function X(_0x58d8c8,_0xf81b11){const _0x43f3e0=a0_0xfef4bc;let _0x2be187=_0xf81b11['now']??Date['now'],_0x103485=_0x2be187(),_0x1866ff=(_0xc2036c,_0x56a6aa,_0x28d710,_0x51f71e)=>{const _0x29af13=a0_0x5475;_0xf81b11[_0x29af13(0x241)](O(U({'from_alias':_0x58d8c8[_0x29af13(0x1f2)],'to_alias':_0x58d8c8[_0x29af13(0x224)],'task_id':_0x56a6aa,'parent_task_id':_0x58d8c8[_0x29af13(0x1f7)],'network_id':_0x58d8c8['networkId'],'transport':_0x58d8c8['transport'],'status':_0xc2036c,'duration_ms':_0x2be187()-_0x103485,'lifecycle_tracking':_0x58d8c8[_0x29af13(0x20c)],..._0x28d710!==void 0x0?{'error_code':_0x51f71e||_0x29af13(0x219),'error_message':N(_0x28d710)}:{}})));};_0x1866ff(_0x43f3e0(0x1cb),null);try{let _0x4bc2ea=await _0xf81b11[_0x43f3e0(0x228)](),_0x4bf325=j(_0x4bc2ea);if(_0x4bf325)_0x1866ff('delivered',_0x4bf325);else{if(_0x4bc2ea?.['ok']===!0x1||_0x4bc2ea?.[_0x43f3e0(0x207)])_0x1866ff(_0x43f3e0(0x1d8),_0x4bf325,_0x4bc2ea?.[_0x43f3e0(0x207)]||_0x43f3e0(0x21c),_0x43f3e0(0x206));else _0x1866ff(_0x43f3e0(0x1d8),null,_0x43f3e0(0x215),_0x43f3e0(0x1ed));}return _0x4bc2ea;}catch(_0x2e67ed){throw _0x1866ff(_0x43f3e0(0x1d8),null,_0x2e67ed,'send_failed'),_0x2e67ed;}}async function Y(_0x2d0fc3,_0x50dda4){const _0x439e4c=a0_0xfef4bc;return X({'fromAlias':_0x2d0fc3[_0x439e4c(0x1f2)],'toAlias':_0x2d0fc3[_0x439e4c(0x1e1)],'parentTaskId':_0x2d0fc3[_0x439e4c(0x1f7)]||null,'networkId':_0x2d0fc3[_0x439e4c(0x1cf)]||null,'transport':_0x439e4c(0x1d1),'lifecycleTracking':_0x439e4c(0x1dc)},_0x50dda4);}class $ extends a0_0xde8ec0{[a0_0xfef4bc(0x232)];[a0_0xfef4bc(0x1e1)];[a0_0xfef4bc(0x1f5)];['agent'];[a0_0xfef4bc(0x203)];['heartbeatInterval'];['reconnectDelay'];[a0_0xfef4bc(0x1d9)];[a0_0xfef4bc(0x22d)];['running']=!0x1;constructor(_0x20c1ef){const _0x44fe25=a0_0xfef4bc;super();if(this[_0x44fe25(0x232)]=_0x20c1ef[_0x44fe25(0x232)][_0x44fe25(0x208)](/\/$/,''),this[_0x44fe25(0x1e1)]=_0x20c1ef[_0x44fe25(0x1e1)],this[_0x44fe25(0x1f5)]=_0x20c1ef[_0x44fe25(0x1f5)],this[_0x44fe25(0x236)]=_0x20c1ef[_0x44fe25(0x236)]||_0x44fe25(0x1f9),this[_0x44fe25(0x203)]=_0x44fe25(0x221)+_0x20c1ef[_0x44fe25(0x1e1)]+'-'+Date[_0x44fe25(0x1fd)]()[_0x44fe25(0x220)](0x24),this[_0x44fe25(0x1db)]=_0x20c1ef[_0x44fe25(0x1db)]??0x2bf20,this[_0x44fe25(0x1ee)]=_0x20c1ef[_0x44fe25(0x1ee)]??0xbb8,_0x20c1ef['autoConnect']!==!0x1)this[_0x44fe25(0x230)]();}[a0_0xfef4bc(0x241)](_0xaa5b68){const _0x4104dc=a0_0xfef4bc;console[_0x4104dc(0x241)]('['+new Date()['toTimeString']()[_0x4104dc(0x1d5)](0x0,0x8)+_0x4104dc(0x225)+this[_0x4104dc(0x1e1)]+']\x20'+_0xaa5b68);}async[a0_0xfef4bc(0x1e4)](_0x5d6d20,_0x4bd500){const _0x168a54=a0_0xfef4bc;let _0x1c7ca9={'Content-Type':'application/json','Accept':_0x168a54(0x1fe)};if(this['token'])_0x1c7ca9[_0x168a54(0x1ea)]='Bearer\x20'+this[_0x168a54(0x1f5)];let _0x2e25b3=await(await fetch(this[_0x168a54(0x232)]+_0x168a54(0x1cd),{'method':'POST','headers':_0x1c7ca9,'body':JSON[_0x168a54(0x226)]({'jsonrpc':_0x168a54(0x238),'id':Date[_0x168a54(0x1fd)](),'method':_0x168a54(0x1d7),'params':{'name':_0x5d6d20,'arguments':_0x4bd500}})}))[_0x168a54(0x1c8)](),_0x333443=_0x2e25b3[_0x168a54(0x218)](/data: (.+)/),_0x1bddba=_0x333443?JSON[_0x168a54(0x20b)](_0x333443[0x1]):JSON[_0x168a54(0x20b)](_0x2e25b3),_0x2deae6=_0x1bddba?.['result']?.['content']?.[0x0]?.[_0x168a54(0x1c8)];return _0x2deae6?JSON[_0x168a54(0x20b)](_0x2deae6):_0x1bddba;}async[a0_0xfef4bc(0x230)](){const _0x2eb155=a0_0xfef4bc;if(this[_0x2eb155(0x1d4)])return;this[_0x2eb155(0x1d4)]=!0x0,await this['status'](_0x2eb155(0x21f)),this['log']('registered'),this['heartbeatTimer']=setInterval(()=>{const _0x31f2b8=_0x2eb155;this['status'](_0x31f2b8(0x21f))[_0x31f2b8(0x1e3)](_0x11e4aa=>this[_0x31f2b8(0x241)]('heartbeat\x20failed:\x20'+_0x11e4aa[_0x31f2b8(0x202)]));},this[_0x2eb155(0x1db)]),this['connectSSE']();}async[a0_0xfef4bc(0x1c5)](){const _0x4c473a=a0_0xfef4bc;if(this[_0x4c473a(0x1d4)]=!0x1,this[_0x4c473a(0x22d)]?.['abort'](),this[_0x4c473a(0x1d9)])clearInterval(this[_0x4c473a(0x1d9)]);await this[_0x4c473a(0x20f)](_0x4c473a(0x21b))[_0x4c473a(0x1e3)](()=>{}),this[_0x4c473a(0x241)](_0x4c473a(0x239));}async[a0_0xfef4bc(0x228)](_0x405ce1,_0x39f4bf,_0x9c4ecd='normal'){const _0x3701f1=a0_0xfef4bc;return Y({'alias':_0x405ce1,'fromAlias':this[_0x3701f1(0x1e1)]},{'log':_0x55323c=>console[_0x3701f1(0x241)](_0x55323c),'send':()=>this[_0x3701f1(0x1e4)](_0x3701f1(0x1ff),{'alias':_0x405ce1,'task':_0x39f4bf,'priority':_0x9c4ecd,'from_session':this[_0x3701f1(0x1e1)]})});}async[a0_0xfef4bc(0x202)](_0x1c97e2,_0xd4a863){const _0xa9b3f6=a0_0xfef4bc;return this[_0xa9b3f6(0x1e4)](_0xa9b3f6(0x22e),{'alias':_0x1c97e2,'message':_0xd4a863,'from_session':this[_0xa9b3f6(0x1e1)]});}async[a0_0xfef4bc(0x1ec)](_0x1e3b27,_0x254526,_0x22b286=a0_0xfef4bc(0x235)){const _0x3bb55a=a0_0xfef4bc;return this['call'](_0x3bb55a(0x22c),{'in_reply_to':_0x1e3b27,'text':_0x254526,'status':_0x22b286});}async[a0_0xfef4bc(0x20f)](_0x5ef7ff,_0x4bbf98){const _0x4e2a82=a0_0xfef4bc;return this[_0x4e2a82(0x1e4)](_0x4e2a82(0x231),{'resume_id':this['resumeId'],'alias':this[_0x4e2a82(0x1e1)],'status':_0x5ef7ff,'server':a0_0x42df73(),'hostname':a0_0x42df73(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x4bbf98});}async[a0_0xfef4bc(0x205)](){const _0xc91328=a0_0xfef4bc;return this[_0xc91328(0x1e4)](_0xc91328(0x23c),{});}async[a0_0xfef4bc(0x22f)](_0x5e485b,_0x2adaf4){const _0x12ef6b=a0_0xfef4bc;return this['call'](_0x12ef6b(0x22f),{'message':_0x5e485b,'filter_server':_0x2adaf4?.[_0x12ef6b(0x1c9)],'filter_status':_0x2adaf4?.[_0x12ef6b(0x20f)]});}async[a0_0xfef4bc(0x222)](){const _0x1f4c2f=a0_0xfef4bc;let _0x376a9c=encodeURIComponent(this[_0x1f4c2f(0x1e1)]),_0x586f4f=this[_0x1f4c2f(0x232)]+_0x1f4c2f(0x201)+_0x376a9c,_0x1dcb88=this[_0x1f4c2f(0x1ee)];while(this[_0x1f4c2f(0x1d4)]){try{this['sseAbort']=new AbortController();let _0x57c3b0={'Accept':'text/event-stream'};if(this[_0x1f4c2f(0x1f5)])_0x57c3b0['Authorization']=_0x1f4c2f(0x1eb)+this['token'];let _0x1f79fa=await fetch(_0x586f4f,{'headers':_0x57c3b0,'signal':this[_0x1f4c2f(0x22d)]['signal']});if(!_0x1f79fa['ok']||!_0x1f79fa[_0x1f4c2f(0x210)]){this[_0x1f4c2f(0x241)]('SSE\x20failed:\x20'+_0x1f79fa[_0x1f4c2f(0x20f)]),await this[_0x1f4c2f(0x1ca)](_0x1dcb88),_0x1dcb88=Math[_0x1f4c2f(0x1f6)](_0x1dcb88*1.5,0xea60);continue;}_0x1dcb88=this['reconnectDelay'];let _0xdf44ba=_0x1f79fa[_0x1f4c2f(0x210)][_0x1f4c2f(0x242)](),_0x262c9c=new TextDecoder(),_0x2ec388='';while(this['running']){let {done:_0x115797,value:_0x5848ed}=await _0xdf44ba[_0x1f4c2f(0x1fc)]();if(_0x115797)break;_0x2ec388+=_0x262c9c[_0x1f4c2f(0x1dd)](_0x5848ed,{'stream':!0x0});let _0x137d35=_0x2ec388[_0x1f4c2f(0x240)]('\x0a');_0x2ec388=_0x137d35[_0x1f4c2f(0x216)]()||'';for(let _0x37ff23 of _0x137d35){if(!_0x37ff23[_0x1f4c2f(0x20a)](_0x1f4c2f(0x1d2)))continue;try{let _0x2a17dd=JSON[_0x1f4c2f(0x20b)](_0x37ff23['slice'](0x6));if(_0x2a17dd[_0x1f4c2f(0x1e5)]==='connected'){this['log']('SSE\x20connected'),this[_0x1f4c2f(0x211)](_0x1f4c2f(0x20d));continue;}if(_0x2a17dd[_0x1f4c2f(0x1e5)]===_0x1f4c2f(0x1e7)||_0x2a17dd[_0x1f4c2f(0x1e5)]===_0x1f4c2f(0x23d)||_0x2a17dd[_0x1f4c2f(0x1e5)]===_0x1f4c2f(0x22f))await this[_0x1f4c2f(0x227)]();}catch{}}}}catch(_0x576c6c){if(_0x576c6c[_0x1f4c2f(0x1f0)]===_0x1f4c2f(0x1fa))break;this[_0x1f4c2f(0x211)](_0x1f4c2f(0x207),_0x576c6c),this[_0x1f4c2f(0x241)](_0x1f4c2f(0x1f4)+_0x576c6c[_0x1f4c2f(0x202)]);}if(this['running'])this[_0x1f4c2f(0x211)]('disconnected'),this['log'](_0x1f4c2f(0x223)+_0x1dcb88/0x3e8+_0x1f4c2f(0x21e)),await this[_0x1f4c2f(0x1ca)](_0x1dcb88),_0x1dcb88=Math['min'](_0x1dcb88*1.5,0xea60);}}async['processInbox'](){const _0x327ce0=a0_0xfef4bc;try{let _0x1c6206=(await this[_0x327ce0(0x1e4)](_0x327ce0(0x234),{'alias':this[_0x327ce0(0x1e1)],'limit':0xa}))?.[_0x327ce0(0x243)]||[];for(let _0x2450e3 of _0x1c6206)await this['call']('ack_inbox',{'alias':this['alias'],'message_id':_0x2450e3['id']}),this['log']('←\x20'+_0x2450e3[_0x327ce0(0x1c4)]+':\x20'+_0x2450e3[_0x327ce0(0x209)][_0x327ce0(0x1d5)](0x0,0x3c)),this[_0x327ce0(0x211)](_0x327ce0(0x1f1),_0x2450e3),this[_0x327ce0(0x211)]('message',_0x2450e3);}catch(_0x3f07ec){this[_0x327ce0(0x241)](_0x327ce0(0x217)+_0x3f07ec['message']);}}['sleep'](_0x1b9c27){return new Promise(_0x3d3566=>setTimeout(_0x3d3566,_0x1b9c27));}}var F=$;export{F as default,$ as CommHub};
|