@sleep2agi/agent-network 2.3.0-preview.7 → 2.3.0-preview.8

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.
@@ -1 +1 @@
1
- const a0_0x399040=a0_0x340f;(function(_0x39361b,_0x4180f8){const _0x315c67=a0_0x340f,_0x271cd3=_0x39361b();while(!![]){try{const _0x5a31d2=-parseInt(_0x315c67(0x142))/0x1*(-parseInt(_0x315c67(0x110))/0x2)+-parseInt(_0x315c67(0x149))/0x3+-parseInt(_0x315c67(0x15c))/0x4*(-parseInt(_0x315c67(0x130))/0x5)+-parseInt(_0x315c67(0x155))/0x6+parseInt(_0x315c67(0x118))/0x7*(parseInt(_0x315c67(0x153))/0x8)+parseInt(_0x315c67(0x11a))/0x9+parseInt(_0x315c67(0x12a))/0xa*(-parseInt(_0x315c67(0x147))/0xb);if(_0x5a31d2===_0x4180f8)break;else _0x271cd3['push'](_0x271cd3['shift']());}catch(_0x4b1e5a){_0x271cd3['push'](_0x271cd3['shift']());}}}(a0_0x5a89,0x54140));import{EventEmitter as a0_0x55ec56}from'events';function a0_0x340f(_0x5ea411,_0x424a15){_0x5ea411=_0x5ea411-0x108;const _0x5a89f0=a0_0x5a89();let _0x340f9e=_0x5a89f0[_0x5ea411];return _0x340f9e;}function a0_0x5a89(){const _0x31783e=['get_inbox','send_message','application/json,\x20text/event-stream','pop','min','send','report_status','2AnWlsV','offline','processInbox','heartbeatTimer','message','connect','autoConnect','ack_inbox','128996RRPghX','AbortError','5791725jsDCBh','catch','read','content','now','application/json','sseAbort','/events/','sdk-','task','getAllStatus','resumeId','startsWith','token','cwd','completed','6028210yecmod','heartbeatInterval','status','inbox\x20error:\x20','registered','heartbeat\x20failed:\x20','743455qDgZJb','url','result','replace','type','server','getReader','alias','reply','name','error','messages','POST','call',']\x20[commhub:','SSE\x20connected','disconnected','sdk','683419MzHxpd','abort','connectSSE','Authorization','disconnect','11GkgKBc','emit','2029374jmbGrS','sleep','agent','toTimeString','send_task','text','/mcp','broadcast','toString','body','152kdkLSg','new_task','3889062KUpUJH','log','parse','slice','Bearer\x20','idle','signal','16QlcPHD','split','reconnectDelay','text/event-stream','running'];a0_0x5a89=function(){return _0x31783e;};return a0_0x5a89();}import{hostname as a0_0x236b0c}from'os';class T extends a0_0x55ec56{['url'];['alias'];[a0_0x399040(0x127)];[a0_0x399040(0x14b)];[a0_0x399040(0x125)];[a0_0x399040(0x12b)];[a0_0x399040(0x15e)];[a0_0x399040(0x113)];['sseAbort'];[a0_0x399040(0x108)]=!0x1;constructor(_0x57aedd){const _0x5c20d6=a0_0x399040;super();if(this[_0x5c20d6(0x131)]=_0x57aedd[_0x5c20d6(0x131)][_0x5c20d6(0x133)](/\/$/,''),this['alias']=_0x57aedd[_0x5c20d6(0x137)],this[_0x5c20d6(0x127)]=_0x57aedd[_0x5c20d6(0x127)],this[_0x5c20d6(0x14b)]=_0x57aedd[_0x5c20d6(0x14b)]||_0x5c20d6(0x141),this[_0x5c20d6(0x125)]=_0x5c20d6(0x122)+_0x57aedd['alias']+'-'+Date[_0x5c20d6(0x11e)]()[_0x5c20d6(0x151)](0x24),this[_0x5c20d6(0x12b)]=_0x57aedd[_0x5c20d6(0x12b)]??0x2bf20,this['reconnectDelay']=_0x57aedd['reconnectDelay']??0xbb8,_0x57aedd[_0x5c20d6(0x116)]!==!0x1)this['connect']();}[a0_0x399040(0x156)](_0x2e1f5f){const _0xfaeef9=a0_0x399040;console['log']('['+new Date()[_0xfaeef9(0x14c)]()[_0xfaeef9(0x158)](0x0,0x8)+_0xfaeef9(0x13e)+this['alias']+']\x20'+_0x2e1f5f);}async['call'](_0x32db5e,_0x4993e1){const _0x25c2d5=a0_0x399040;let _0x50ec78={'Content-Type':_0x25c2d5(0x11f),'Accept':_0x25c2d5(0x10b)};if(this[_0x25c2d5(0x127)])_0x50ec78[_0x25c2d5(0x145)]=_0x25c2d5(0x159)+this['token'];let _0x19eff5=await(await fetch(this[_0x25c2d5(0x131)]+_0x25c2d5(0x14f),{'method':_0x25c2d5(0x13c),'headers':_0x50ec78,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date['now'](),'method':'tools/call','params':{'name':_0x32db5e,'arguments':_0x4993e1}})}))[_0x25c2d5(0x14e)](),_0xa1ada5=_0x19eff5['match'](/data: (.+)/),_0x172873=_0xa1ada5?JSON[_0x25c2d5(0x157)](_0xa1ada5[0x1]):JSON['parse'](_0x19eff5),_0x286359=_0x172873?.[_0x25c2d5(0x132)]?.[_0x25c2d5(0x11d)]?.[0x0]?.[_0x25c2d5(0x14e)];return _0x286359?JSON[_0x25c2d5(0x157)](_0x286359):_0x172873;}async[a0_0x399040(0x115)](){const _0x4c706f=a0_0x399040;if(this[_0x4c706f(0x108)])return;this[_0x4c706f(0x108)]=!0x0,await this[_0x4c706f(0x12c)](_0x4c706f(0x15a)),this['log'](_0x4c706f(0x12e)),this[_0x4c706f(0x113)]=setInterval(()=>{const _0x5bddf2=_0x4c706f;this[_0x5bddf2(0x12c)](_0x5bddf2(0x15a))['catch'](_0x9c819b=>this[_0x5bddf2(0x156)](_0x5bddf2(0x12f)+_0x9c819b['message']));},this['heartbeatInterval']),this[_0x4c706f(0x144)]();}async[a0_0x399040(0x146)](){const _0x578f3e=a0_0x399040;if(this['running']=!0x1,this['sseAbort']?.[_0x578f3e(0x143)](),this[_0x578f3e(0x113)])clearInterval(this[_0x578f3e(0x113)]);await this[_0x578f3e(0x12c)](_0x578f3e(0x111))[_0x578f3e(0x11b)](()=>{}),this[_0x578f3e(0x156)](_0x578f3e(0x140));}async[a0_0x399040(0x10e)](_0x30a6e0,_0x587824,_0x3fb8ac='normal'){const _0x4203ac=a0_0x399040;return this['call'](_0x4203ac(0x14d),{'alias':_0x30a6e0,'task':_0x587824,'priority':_0x3fb8ac,'from_session':this['alias']});}async[a0_0x399040(0x114)](_0x5bcff8,_0x3108bf){const _0x4d65d5=a0_0x399040;return this[_0x4d65d5(0x13d)](_0x4d65d5(0x10a),{'alias':_0x5bcff8,'message':_0x3108bf,'from_session':this[_0x4d65d5(0x137)]});}async[a0_0x399040(0x138)](_0x41a286,_0x20add6,_0x1d8e7c=a0_0x399040(0x129)){const _0x36fa1f=a0_0x399040;return this[_0x36fa1f(0x13d)]('send_reply',{'in_reply_to':_0x41a286,'text':_0x20add6,'status':_0x1d8e7c});}async['status'](_0x18ece1,_0x2352f3){const _0x573b42=a0_0x399040;return this[_0x573b42(0x13d)](_0x573b42(0x10f),{'resume_id':this[_0x573b42(0x125)],'alias':this[_0x573b42(0x137)],'status':_0x18ece1,'server':a0_0x236b0c(),'hostname':a0_0x236b0c(),'agent':this[_0x573b42(0x14b)],'project_dir':process[_0x573b42(0x128)](),..._0x2352f3});}async[a0_0x399040(0x124)](){const _0x5825f9=a0_0x399040;return this[_0x5825f9(0x13d)]('get_all_status',{});}async[a0_0x399040(0x150)](_0x16d6d3,_0x41cfe1){const _0x3aa5fe=a0_0x399040;return this[_0x3aa5fe(0x13d)](_0x3aa5fe(0x150),{'message':_0x16d6d3,'filter_server':_0x41cfe1?.[_0x3aa5fe(0x135)],'filter_status':_0x41cfe1?.[_0x3aa5fe(0x12c)]});}async[a0_0x399040(0x144)](){const _0x532a18=a0_0x399040;let _0x114f53=encodeURIComponent(this[_0x532a18(0x137)]),_0x5df645=this[_0x532a18(0x131)]+_0x532a18(0x121)+_0x114f53,_0x10afd0=this[_0x532a18(0x15e)];while(this['running']){try{this[_0x532a18(0x120)]=new AbortController();let _0x1bd2b5={'Accept':_0x532a18(0x15f)};if(this[_0x532a18(0x127)])_0x1bd2b5['Authorization']='Bearer\x20'+this[_0x532a18(0x127)];let _0x195262=await fetch(_0x5df645,{'headers':_0x1bd2b5,'signal':this[_0x532a18(0x120)][_0x532a18(0x15b)]});if(!_0x195262['ok']||!_0x195262[_0x532a18(0x152)]){this[_0x532a18(0x156)]('SSE\x20failed:\x20'+_0x195262[_0x532a18(0x12c)]),await this[_0x532a18(0x14a)](_0x10afd0),_0x10afd0=Math['min'](_0x10afd0*1.5,0xea60);continue;}_0x10afd0=this['reconnectDelay'];let _0x673f17=_0x195262['body'][_0x532a18(0x136)](),_0x526c55=new TextDecoder(),_0x3d58f6='';while(this[_0x532a18(0x108)]){let {done:_0x185423,value:_0x52b3aa}=await _0x673f17[_0x532a18(0x11c)]();if(_0x185423)break;_0x3d58f6+=_0x526c55['decode'](_0x52b3aa,{'stream':!0x0});let _0x113149=_0x3d58f6[_0x532a18(0x15d)]('\x0a');_0x3d58f6=_0x113149[_0x532a18(0x10c)]()||'';for(let _0xda92e9 of _0x113149){if(!_0xda92e9[_0x532a18(0x126)]('data:\x20'))continue;try{let _0x297867=JSON[_0x532a18(0x157)](_0xda92e9['slice'](0x6));if(_0x297867[_0x532a18(0x134)]==='connected'){this[_0x532a18(0x156)](_0x532a18(0x13f)),this[_0x532a18(0x148)]('connected');continue;}if(_0x297867[_0x532a18(0x134)]===_0x532a18(0x154)||_0x297867[_0x532a18(0x134)]==='new_message'||_0x297867['type']===_0x532a18(0x150))await this[_0x532a18(0x112)]();}catch{}}}}catch(_0x4c7cae){if(_0x4c7cae[_0x532a18(0x139)]===_0x532a18(0x119))break;this[_0x532a18(0x148)](_0x532a18(0x13a),_0x4c7cae),this[_0x532a18(0x156)]('SSE\x20error:\x20'+_0x4c7cae[_0x532a18(0x114)]);}if(this[_0x532a18(0x108)])this[_0x532a18(0x148)](_0x532a18(0x140)),this['log']('SSE\x20reconnecting\x20in\x20'+_0x10afd0/0x3e8+'s...'),await this[_0x532a18(0x14a)](_0x10afd0),_0x10afd0=Math[_0x532a18(0x10d)](_0x10afd0*1.5,0xea60);}}async[a0_0x399040(0x112)](){const _0x1bd4ba=a0_0x399040;try{let _0x344cd2=(await this[_0x1bd4ba(0x13d)](_0x1bd4ba(0x109),{'alias':this['alias'],'limit':0xa}))?.[_0x1bd4ba(0x13b)]||[];for(let _0x5244ff of _0x344cd2)await this['call'](_0x1bd4ba(0x117),{'alias':this[_0x1bd4ba(0x137)],'message_id':_0x5244ff['id']}),this[_0x1bd4ba(0x156)]('←\x20'+_0x5244ff['from_session']+':\x20'+_0x5244ff[_0x1bd4ba(0x11d)][_0x1bd4ba(0x158)](0x0,0x3c)),this['emit'](_0x1bd4ba(0x123),_0x5244ff),this[_0x1bd4ba(0x148)](_0x1bd4ba(0x114),_0x5244ff);}catch(_0xe0b16d){this['log'](_0x1bd4ba(0x12d)+_0xe0b16d['message']);}}[a0_0x399040(0x14a)](_0x576196){return new Promise(_0x278a9=>setTimeout(_0x278a9,_0x576196));}}var $=T;export{$ as default,T as CommHub};
1
+ function a0_0x1a4b(_0x5ed33c,_0x30db5b){_0x5ed33c=_0x5ed33c-0x1af;const _0x540cb8=a0_0x540c();let _0x1a4b8b=_0x540cb8[_0x5ed33c];return _0x1a4b8b;}function a0_0x540c(){const _0x3398ef=['token','application/json,\x20text/event-stream','url','3914220FIWCCn','send','/mcp','reply','normal','startsWith','sleep','11863380WleNBg','call','disconnected','task','autoConnect','content','heartbeatTimer','reconnectDelay','1545160KwkaFo','155352EoYLMU','resumeId','registered','slice','6095826qgqwrY','now','completed','toString','getReader','1593675CrzaxG','SSE\x20connected','Authorization','running','sseAbort','log','356WNFEnM','match','name','/events/','heartbeatInterval','processInbox','send_reply','abort','pop','message','offline','connect','AbortError','new_message','4924LlUXBE','text','2.0','emit','report_status','broadcast','sdk','type','status','min','error','get_all_status','Bearer\x20','cwd','sdk-','read','idle','connected','catch','agent','connectSSE','4lWDeOd','alias','parse','new_task','231oYXYZH','application/json','SSE\x20reconnecting\x20in\x20','text/event-stream','result','signal','stringify'];a0_0x540c=function(){return _0x3398ef;};return a0_0x540c();}const a0_0x999825=a0_0x1a4b;(function(_0x4c66d1,_0x418324){const _0x1d1d05=a0_0x1a4b,_0xd91cc0=_0x4c66d1();while(!![]){try{const _0x1f6b79=-parseInt(_0x1d1d05(0x1db))/0x1*(parseInt(_0x1d1d05(0x1cd))/0x2)+parseInt(_0x1d1d05(0x1c7))/0x3+-parseInt(_0x1d1d05(0x1f0))/0x4*(-parseInt(_0x1d1d05(0x1bd))/0x5)+parseInt(_0x1d1d05(0x1fe))/0x6+parseInt(_0x1d1d05(0x1f4))/0x7*(-parseInt(_0x1d1d05(0x1be))/0x8)+-parseInt(_0x1d1d05(0x1c2))/0x9+parseInt(_0x1d1d05(0x1b5))/0xa;if(_0x1f6b79===_0x418324)break;else _0xd91cc0['push'](_0xd91cc0['shift']());}catch(_0x32d0bb){_0xd91cc0['push'](_0xd91cc0['shift']());}}}(a0_0x540c,0x76400));import{EventEmitter as a0_0x5183e4}from'events';import{hostname as a0_0x40be42}from'os';class T extends a0_0x5183e4{[a0_0x999825(0x1fd)];[a0_0x999825(0x1f1)];['token'];[a0_0x999825(0x1ee)];[a0_0x999825(0x1bf)];[a0_0x999825(0x1d1)];[a0_0x999825(0x1bc)];[a0_0x999825(0x1bb)];[a0_0x999825(0x1cb)];[a0_0x999825(0x1ca)]=!0x1;constructor(_0x4f27da){const _0xac7ce3=a0_0x999825;super();if(this[_0xac7ce3(0x1fd)]=_0x4f27da[_0xac7ce3(0x1fd)]['replace'](/\/$/,''),this[_0xac7ce3(0x1f1)]=_0x4f27da['alias'],this['token']=_0x4f27da[_0xac7ce3(0x1fb)],this[_0xac7ce3(0x1ee)]=_0x4f27da[_0xac7ce3(0x1ee)]||_0xac7ce3(0x1e1),this[_0xac7ce3(0x1bf)]=_0xac7ce3(0x1e9)+_0x4f27da['alias']+'-'+Date[_0xac7ce3(0x1c3)]()[_0xac7ce3(0x1c5)](0x24),this[_0xac7ce3(0x1d1)]=_0x4f27da[_0xac7ce3(0x1d1)]??0x2bf20,this[_0xac7ce3(0x1bc)]=_0x4f27da[_0xac7ce3(0x1bc)]??0xbb8,_0x4f27da[_0xac7ce3(0x1b9)]!==!0x1)this[_0xac7ce3(0x1d8)]();}[a0_0x999825(0x1cc)](_0x9d2f4){const _0x25f00c=a0_0x999825;console[_0x25f00c(0x1cc)]('['+new Date()['toTimeString']()[_0x25f00c(0x1c1)](0x0,0x8)+']\x20[commhub:'+this[_0x25f00c(0x1f1)]+']\x20'+_0x9d2f4);}async[a0_0x999825(0x1b6)](_0x2d02b7,_0x5e23f1){const _0x582642=a0_0x999825;let _0x1f8b3d={'Content-Type':_0x582642(0x1f5),'Accept':_0x582642(0x1fc)};if(this[_0x582642(0x1fb)])_0x1f8b3d[_0x582642(0x1c9)]=_0x582642(0x1e7)+this[_0x582642(0x1fb)];let _0x13e135=await(await fetch(this[_0x582642(0x1fd)]+_0x582642(0x1b0),{'method':'POST','headers':_0x1f8b3d,'body':JSON[_0x582642(0x1fa)]({'jsonrpc':_0x582642(0x1dd),'id':Date[_0x582642(0x1c3)](),'method':'tools/call','params':{'name':_0x2d02b7,'arguments':_0x5e23f1}})}))[_0x582642(0x1dc)](),_0x38ecf4=_0x13e135[_0x582642(0x1ce)](/data: (.+)/),_0x23767f=_0x38ecf4?JSON[_0x582642(0x1f2)](_0x38ecf4[0x1]):JSON[_0x582642(0x1f2)](_0x13e135),_0x56f3dc=_0x23767f?.[_0x582642(0x1f8)]?.[_0x582642(0x1ba)]?.[0x0]?.['text'];return _0x56f3dc?JSON[_0x582642(0x1f2)](_0x56f3dc):_0x23767f;}async[a0_0x999825(0x1d8)](){const _0x183084=a0_0x999825;if(this[_0x183084(0x1ca)])return;this[_0x183084(0x1ca)]=!0x0,await this[_0x183084(0x1e3)](_0x183084(0x1eb)),this['log'](_0x183084(0x1c0)),this['heartbeatTimer']=setInterval(()=>{const _0x153a01=_0x183084;this[_0x153a01(0x1e3)](_0x153a01(0x1eb))['catch'](_0xf3a729=>this[_0x153a01(0x1cc)]('heartbeat\x20failed:\x20'+_0xf3a729[_0x153a01(0x1d6)]));},this[_0x183084(0x1d1)]),this[_0x183084(0x1ef)]();}async['disconnect'](){const _0x3cdf0b=a0_0x999825;if(this['running']=!0x1,this[_0x3cdf0b(0x1cb)]?.[_0x3cdf0b(0x1d4)](),this[_0x3cdf0b(0x1bb)])clearInterval(this[_0x3cdf0b(0x1bb)]);await this['status'](_0x3cdf0b(0x1d7))[_0x3cdf0b(0x1ed)](()=>{}),this['log'](_0x3cdf0b(0x1b7));}async[a0_0x999825(0x1af)](_0x3f7ba0,_0x566f3b,_0x3da99c=a0_0x999825(0x1b2)){const _0x241cdf=a0_0x999825;return this[_0x241cdf(0x1b6)]('send_task',{'alias':_0x3f7ba0,'task':_0x566f3b,'priority':_0x3da99c,'from_session':this[_0x241cdf(0x1f1)]});}async['message'](_0x13f328,_0x254f4e){const _0x1d713b=a0_0x999825;return this[_0x1d713b(0x1b6)]('send_message',{'alias':_0x13f328,'message':_0x254f4e,'from_session':this[_0x1d713b(0x1f1)]});}async[a0_0x999825(0x1b1)](_0xe7466a,_0x478922,_0x2f203e=a0_0x999825(0x1c4)){const _0x21f4a5=a0_0x999825;return this[_0x21f4a5(0x1b6)](_0x21f4a5(0x1d3),{'in_reply_to':_0xe7466a,'text':_0x478922,'status':_0x2f203e});}async['status'](_0x5c6444,_0x5095b1){const _0x449cc6=a0_0x999825;return this[_0x449cc6(0x1b6)](_0x449cc6(0x1df),{'resume_id':this[_0x449cc6(0x1bf)],'alias':this[_0x449cc6(0x1f1)],'status':_0x5c6444,'server':a0_0x40be42(),'hostname':a0_0x40be42(),'agent':this[_0x449cc6(0x1ee)],'project_dir':process[_0x449cc6(0x1e8)](),..._0x5095b1});}async['getAllStatus'](){const _0x1f1762=a0_0x999825;return this[_0x1f1762(0x1b6)](_0x1f1762(0x1e6),{});}async[a0_0x999825(0x1e0)](_0x581001,_0x5c146d){const _0x229538=a0_0x999825;return this['call'](_0x229538(0x1e0),{'message':_0x581001,'filter_server':_0x5c146d?.['server'],'filter_status':_0x5c146d?.[_0x229538(0x1e3)]});}async[a0_0x999825(0x1ef)](){const _0x468c96=a0_0x999825;let _0x243ca8=encodeURIComponent(this['alias']),_0x13ba31=this[_0x468c96(0x1fd)]+_0x468c96(0x1d0)+_0x243ca8,_0x320db5=this[_0x468c96(0x1bc)];while(this[_0x468c96(0x1ca)]){try{this['sseAbort']=new AbortController();let _0x5c46cb={'Accept':_0x468c96(0x1f7)};if(this['token'])_0x5c46cb[_0x468c96(0x1c9)]=_0x468c96(0x1e7)+this[_0x468c96(0x1fb)];let _0x2a4087=await fetch(_0x13ba31,{'headers':_0x5c46cb,'signal':this[_0x468c96(0x1cb)][_0x468c96(0x1f9)]});if(!_0x2a4087['ok']||!_0x2a4087['body']){this['log']('SSE\x20failed:\x20'+_0x2a4087[_0x468c96(0x1e3)]),await this[_0x468c96(0x1b4)](_0x320db5),_0x320db5=Math[_0x468c96(0x1e4)](_0x320db5*1.5,0xea60);continue;}_0x320db5=this[_0x468c96(0x1bc)];let _0x24dc80=_0x2a4087['body'][_0x468c96(0x1c6)](),_0x2e483c=new TextDecoder(),_0x1c1ce3='';while(this[_0x468c96(0x1ca)]){let {done:_0x20fc68,value:_0x1314c0}=await _0x24dc80[_0x468c96(0x1ea)]();if(_0x20fc68)break;_0x1c1ce3+=_0x2e483c['decode'](_0x1314c0,{'stream':!0x0});let _0x45d15e=_0x1c1ce3['split']('\x0a');_0x1c1ce3=_0x45d15e[_0x468c96(0x1d5)]()||'';for(let _0x234929 of _0x45d15e){if(!_0x234929[_0x468c96(0x1b3)]('data:\x20'))continue;try{let _0x37ea62=JSON[_0x468c96(0x1f2)](_0x234929[_0x468c96(0x1c1)](0x6));if(_0x37ea62[_0x468c96(0x1e2)]===_0x468c96(0x1ec)){this['log'](_0x468c96(0x1c8)),this[_0x468c96(0x1de)](_0x468c96(0x1ec));continue;}if(_0x37ea62['type']===_0x468c96(0x1f3)||_0x37ea62[_0x468c96(0x1e2)]===_0x468c96(0x1da)||_0x37ea62[_0x468c96(0x1e2)]==='broadcast')await this[_0x468c96(0x1d2)]();}catch{}}}}catch(_0x26936b){if(_0x26936b[_0x468c96(0x1cf)]===_0x468c96(0x1d9))break;this[_0x468c96(0x1de)](_0x468c96(0x1e5),_0x26936b),this[_0x468c96(0x1cc)]('SSE\x20error:\x20'+_0x26936b[_0x468c96(0x1d6)]);}if(this[_0x468c96(0x1ca)])this[_0x468c96(0x1de)](_0x468c96(0x1b7)),this[_0x468c96(0x1cc)](_0x468c96(0x1f6)+_0x320db5/0x3e8+'s...'),await this['sleep'](_0x320db5),_0x320db5=Math[_0x468c96(0x1e4)](_0x320db5*1.5,0xea60);}}async[a0_0x999825(0x1d2)](){const _0x578893=a0_0x999825;try{let _0x2392a8=(await this['call']('get_inbox',{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x4474fc of _0x2392a8)await this[_0x578893(0x1b6)]('ack_inbox',{'alias':this[_0x578893(0x1f1)],'message_id':_0x4474fc['id']}),this[_0x578893(0x1cc)]('←\x20'+_0x4474fc['from_session']+':\x20'+_0x4474fc[_0x578893(0x1ba)]['slice'](0x0,0x3c)),this[_0x578893(0x1de)](_0x578893(0x1b8),_0x4474fc),this['emit'](_0x578893(0x1d6),_0x4474fc);}catch(_0x1c4649){this[_0x578893(0x1cc)]('inbox\x20error:\x20'+_0x1c4649['message']);}}['sleep'](_0x5b8686){return new Promise(_0x304075=>setTimeout(_0x304075,_0x5b8686));}}var $=T;export{$ as default,T as CommHub};
@@ -57,4 +57,35 @@ export declare class FeishuAdapter implements IMAdapter {
57
57
  * `|` and `**`).
58
58
  */
59
59
  export declare function looksLikeMarkdown(text: string): boolean;
60
+ /**
61
+ * Parse Feishu `message_type: "post"` content into plain text. Post
62
+ * content is a nested structure:
63
+ *
64
+ * { title?: string,
65
+ * content: Array<Array<{ tag: "text"|"img"|"a"|"at"|"emotion", ... }>>
66
+ * }
67
+ *
68
+ * Each top-level array entry is a paragraph; each paragraph is an array
69
+ * of typed segments. We flatten by:
70
+ * - prepending title (if present) as `<title>\n\n`
71
+ * - joining paragraphs with `\n\n`
72
+ * - joining segments within a paragraph in order
73
+ * - tag=text → emit segment.text as-is
74
+ * - tag=a → emit `[label](href)` (markdown link)
75
+ * - tag=at → emit `@user_name` (fallback to `@<user_id>` if no name)
76
+ * - tag=img → emit `[图片]` placeholder (actual download via maybeAttachImages)
77
+ * - tag=emotion → emit `[emoji]`
78
+ * - unknown tag → skip
79
+ *
80
+ * @internal exported for unit tests.
81
+ */
82
+ export declare function parsePostContent(rawJson: string): string;
83
+ /**
84
+ * Walk a Feishu `post` content JSON and collect all `image_key` values
85
+ * from `tag: "img"` segments. Used by `maybeAttachImages` to schedule
86
+ * downloads for every image in a 图文混排 message.
87
+ *
88
+ * @internal exported for unit tests.
89
+ */
90
+ export declare function extractPostImageKeys(rawJson: string): string[];
60
91
  export {};
@@ -0,0 +1,61 @@
1
+ /**
2
+ * RFC-020 §14 — markdown → image rendering for Feishu replies.
3
+ *
4
+ * Vincent 2026-06-29 path: Feishu's `markdown` card element doesn't
5
+ * render ATX headings or GFM tables (preview.7 caught only bold / list
6
+ * / link). Rather than partially support a moving subset of card
7
+ * elements, we render structured markdown to a PNG via headless
8
+ * chromium and send it through Feishu's image API (`im:resource:upload`
9
+ * scope). Pixel-perfect fidelity, zero schema fragility, text-not-
10
+ * copyable accepted as the tradeoff for "actually renders".
11
+ *
12
+ * Hybrid route (decided in adapter.send):
13
+ * - plain text (no markdown markers) → msg_type:"text"
14
+ * - markdown WITHOUT heading / table / long → msg_type:"interactive" (schema 1.0 card with `markdown` element — keeps copy/paste for short bold/list/link replies; preview.7 path)
15
+ * - markdown WITH heading / table / long → THIS PATH (msg_type:"image" with rendered PNG)
16
+ *
17
+ * Renderer choice: `puppeteer-core` (no bundled chromium) + system
18
+ * chromium (apt install in Docker). Rationale:
19
+ * - Pure-JS canvas-layout libraries (node-canvas, @napi-rs/canvas)
20
+ * cost 4-6h of manual paragraph wrapping + table cell measurement
21
+ * + Chinese width metrics; chromium does this natively.
22
+ * - puppeteer-core (5MB) + system chromium (~100MB) is smaller than
23
+ * full puppeteer (170MB) which bundles its own chromium.
24
+ * - Headless screenshot ~500ms after warmup. Bot's heavy turn is 20-
25
+ * 70s; rendering cost is in the noise.
26
+ *
27
+ * Chromium reuse: we keep a single browser instance hot across
28
+ * renderings to avoid the ~2-3s cold-start per call. Auto-close on
29
+ * idle is a follow-up — agent-node worker lifetime is bounded.
30
+ */
31
+ import { Buffer } from "node:buffer";
32
+ /**
33
+ * Close the shared browser. Called from adapter.stop() during graceful
34
+ * worker shutdown. Subsequent render calls re-launch.
35
+ */
36
+ export declare function closeBrowser(): Promise<void>;
37
+ /**
38
+ * Render markdown text to a PNG buffer.
39
+ *
40
+ * Width is fixed at 800px (IM-friendly); height auto-fits content via
41
+ * `fullPage:true`. Returns the raw PNG bytes — caller hands them to
42
+ * `lark.im.image.create({image: Readable.from(buffer)})`.
43
+ *
44
+ * Throws on chromium launch failure or page navigation failure.
45
+ * Caller is responsible for fallback (e.g., send the raw text as a
46
+ * code block in the schema 1.0 card path).
47
+ */
48
+ export declare function renderMarkdownToPng(text: string): Promise<Buffer>;
49
+ /**
50
+ * Decide whether `renderMarkdownToPng` should be invoked for this reply
51
+ * text, vs. falling back to msg_type:"text" / msg_type:"interactive"
52
+ * (schema 1.0 card). Locked by 通信龙 3f70044c — trigger image when:
53
+ * - text contains a markdown table (Feishu card can't render)
54
+ * - text contains an ATX heading (Feishu card can't render)
55
+ * - text length > 2000 chars (image is better than scrollable text wall)
56
+ *
57
+ * Returns false for short prose, single-line plain text, and short
58
+ * markdown lists / bold / link / inline-code which DO render fine in
59
+ * the schema 1.0 `markdown` card element.
60
+ */
61
+ export declare function shouldRenderAsImage(text: string): boolean;