@sleep2agi/agent-network 2.3.0-preview.47 → 2.3.0-preview.48

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_0x240860=a0_0xfa02;(function(_0x1d8ce7,_0x619d2b){const _0x491374=a0_0xfa02,_0x2d1699=_0x1d8ce7();while(!![]){try{const _0x259bd5=parseInt(_0x491374(0x10b))/0x1+-parseInt(_0x491374(0x155))/0x2*(-parseInt(_0x491374(0x103))/0x3)+parseInt(_0x491374(0xee))/0x4+-parseInt(_0x491374(0x156))/0x5*(-parseInt(_0x491374(0x14b))/0x6)+parseInt(_0x491374(0xfb))/0x7+parseInt(_0x491374(0xef))/0x8*(-parseInt(_0x491374(0xfa))/0x9)+-parseInt(_0x491374(0x141))/0xa;if(_0x259bd5===_0x619d2b)break;else _0x2d1699['push'](_0x2d1699['shift']());}catch(_0x496f67){_0x2d1699['push'](_0x2d1699['shift']());}}}(a0_0x3927,0xd672b));import{EventEmitter as a0_0x59ad8d}from'events';import{hostname as a0_0x11444b}from'os';var _=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,c=(_0x461794,_0x2c070c)=>(_0x461794??_0x2c070c)[a0_0x240860(0x11a)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x240860(0xeb)](0x0,0xf0);function T(_0x110129){const _0x45541f=a0_0x240860;return(_0x110129 instanceof Error?_0x110129['message']:String(_0x110129??_0x45541f(0x153)))[_0x45541f(0x11a)](_,'[REDACTED]')[_0x45541f(0x11a)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function a0_0x3927(){const _0x50f72f=['fromAlias','delivered','network_id','<missing>','stringify','type','body','decode','CommHub\x20rejected\x20task','min','s...','name','application/json,\x20text/event-stream','parentTaskId','Authorization','getAllStatus','/events/','task.send.start','AbortError','send_rejected','task.ack','sdk-','status','task.replied','send_reply','sseAbort','SSE\x20connected','data:\x20','agent','url','\x20duration_ms=','mcp_http','53074740PLeqkJ','send','error','emit','running','connect','text/event-stream','<pending>','\x20lifecycle=','error_code','10462998TnCzyK','connectSSE','\x20from=','task_id','2.0','string','cwd','disconnected','unknown\x20error','from_alias','2780714bjthvK','5GkBhPn','broadcast','SSE\x20failed:\x20','failed','\x20to=','text','task.send.delivered','toAlias','abort','pop','send_message','split','task.send.failed','heartbeatInterval','SSE\x20reconnecting\x20in\x20','message','content','slice','new_message','transport','6488752vsdIXR','12248LvlAOU','signal','match','disconnect','completed',']\x20[commhub:','token','\x20task_id=','task.expired','sleep','alias','5562JvyHjd','9424828JFssXf','now','parse','getReader','messages','networkId','lifecycle_tracking','sdk','3izNcEU','duration_ms','send_failed','CommHub\x20response\x20omitted\x20task_id','missing_task_id','get_inbox','lifecycleTracking','[commhub:task]\x20','1029229CfQMas','to_alias','message_id','get_all_status','heartbeat\x20failed:\x20','call','inbox\x20error:\x20','<unknown>','log','Bearer\x20','heartbeatTimer','read','\x20network_id=','toTimeString','reconnectDelay','replace','SSE\x20error:\x20','task','new_task','resumeId','registered','sending'];a0_0x3927=function(){return _0x50f72f;};return a0_0x3927();}function y(_0x50dd5b,_0x26c289=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x46a26e=a0_0x240860;if(_0x26c289)return JSON[_0x46a26e(0x125)](_0x50dd5b);let _0x156ad9=c(_0x50dd5b['parent_task_id'],_0x46a26e(0x124)),_0x136b5b=c(_0x50dd5b['task_id'],_0x46a26e(0x148)),_0x5bf3ba=_0x50dd5b[_0x46a26e(0x14a)]?'\x20error='+_0x50dd5b[_0x46a26e(0x14a)]+':'+(_0x50dd5b['error_message']??''):'';return _0x46a26e(0x10a)+_0x50dd5b['status']+_0x46a26e(0x14d)+c(_0x50dd5b[_0x46a26e(0x154)],_0x46a26e(0x112))+_0x46a26e(0x15a)+c(_0x50dd5b[_0x46a26e(0x10c)],'<unknown>')+_0x46a26e(0xf6)+_0x136b5b+'\x20parent_task_id='+_0x156ad9+_0x46a26e(0x117)+c(_0x50dd5b[_0x46a26e(0x123)],_0x46a26e(0x112))+'\x20transport='+_0x50dd5b[_0x46a26e(0xed)]+_0x46a26e(0x13f)+_0x50dd5b[_0x46a26e(0x104)]+_0x46a26e(0x149)+_0x50dd5b[_0x46a26e(0x101)]+_0x5bf3ba;}function b(_0x309e22){const _0x3e8a2e=a0_0x240860;return{'event':{'sending':_0x3e8a2e(0x132),'delivered':_0x3e8a2e(0x15c),'failed':_0x3e8a2e(0x162),'acked':_0x3e8a2e(0x135),'started':'task.started','replied':_0x3e8a2e(0x138),'expired':_0x3e8a2e(0xf7)}[_0x309e22[_0x3e8a2e(0x137)]],..._0x309e22};}function w(_0x485425){const _0x24dc5a=a0_0x240860;let _0x55ef2b=_0x485425?.[_0x24dc5a(0x14e)]||_0x485425?.['message_id']||_0x485425?.['id'];if(_0x55ef2b)return String(_0x55ef2b);let _0x30b2b4=_0x485425?.[_0x24dc5a(0xea)]?.[0x0]?.['text'];if(typeof _0x30b2b4!==_0x24dc5a(0x150))return null;try{let _0x1798c=JSON[_0x24dc5a(0xfd)](_0x30b2b4);return _0x1798c?.[_0x24dc5a(0x14e)]||_0x1798c?.[_0x24dc5a(0x10d)]||_0x1798c?.['id']||null;}catch{return null;}}async function h(_0x45f05f,_0x524841){const _0x5ae68a=a0_0x240860;let _0x5ea059=_0x524841[_0x5ae68a(0xfc)]??Date[_0x5ae68a(0xfc)],_0x133027=_0x5ea059(),_0x4936d7=(_0x33de68,_0x5a571c,_0x41691c,_0xf327e9)=>{const _0x291d1f=_0x5ae68a;_0x524841['log'](y(b({'from_alias':_0x45f05f[_0x291d1f(0x121)],'to_alias':_0x45f05f[_0x291d1f(0x15d)],'task_id':_0x5a571c,'parent_task_id':_0x45f05f[_0x291d1f(0x12e)],'network_id':_0x45f05f[_0x291d1f(0x100)],'transport':_0x45f05f['transport'],'status':_0x33de68,'duration_ms':_0x5ea059()-_0x133027,'lifecycle_tracking':_0x45f05f[_0x291d1f(0x109)],..._0x41691c!==void 0x0?{'error_code':_0xf327e9||_0x291d1f(0x105),'error_message':T(_0x41691c)}:{}})));};_0x4936d7(_0x5ae68a(0x120),null);try{let _0x532c49=await _0x524841['send'](),_0x271066=w(_0x532c49);if(_0x271066)_0x4936d7(_0x5ae68a(0x122),_0x271066);else{if(_0x532c49?.['ok']===!0x1||_0x532c49?.[_0x5ae68a(0x143)])_0x4936d7('failed',_0x271066,_0x532c49?.[_0x5ae68a(0x143)]||_0x5ae68a(0x129),_0x5ae68a(0x134));else _0x4936d7(_0x5ae68a(0x159),null,_0x5ae68a(0x106),_0x5ae68a(0x107));}return _0x532c49;}catch(_0x54d25c){throw _0x4936d7(_0x5ae68a(0x159),null,_0x54d25c,_0x5ae68a(0x105)),_0x54d25c;}}function a0_0xfa02(_0x5ea432,_0x4d7ff6){_0x5ea432=_0x5ea432-0xe8;const _0x392711=a0_0x3927();let _0xfa0231=_0x392711[_0x5ea432];return _0xfa0231;}async function u(_0x58ded2,_0x4e8d76){const _0x46835b=a0_0x240860;return h({'fromAlias':_0x58ded2[_0x46835b(0x121)],'toAlias':_0x58ded2[_0x46835b(0xf9)],'parentTaskId':_0x58ded2[_0x46835b(0x12e)]||null,'networkId':_0x58ded2['networkId']||null,'transport':_0x46835b(0x140),'lifecycleTracking':'not_tracked'},_0x4e8d76);}class k extends a0_0x59ad8d{['url'];[a0_0x240860(0xf9)];[a0_0x240860(0xf5)];[a0_0x240860(0x13d)];['resumeId'];[a0_0x240860(0x163)];[a0_0x240860(0x119)];[a0_0x240860(0x115)];['sseAbort'];[a0_0x240860(0x145)]=!0x1;constructor(_0x550012){const _0x565047=a0_0x240860;super();if(this[_0x565047(0x13e)]=_0x550012[_0x565047(0x13e)][_0x565047(0x11a)](/\/$/,''),this['alias']=_0x550012['alias'],this[_0x565047(0xf5)]=_0x550012['token'],this[_0x565047(0x13d)]=_0x550012[_0x565047(0x13d)]||_0x565047(0x102),this[_0x565047(0x11e)]=_0x565047(0x136)+_0x550012['alias']+'-'+Date[_0x565047(0xfc)]()['toString'](0x24),this[_0x565047(0x163)]=_0x550012['heartbeatInterval']??0x2bf20,this[_0x565047(0x119)]=_0x550012[_0x565047(0x119)]??0xbb8,_0x550012['autoConnect']!==!0x1)this['connect']();}[a0_0x240860(0x113)](_0x4b788e){const _0x5428ea=a0_0x240860;console[_0x5428ea(0x113)]('['+new Date()[_0x5428ea(0x118)]()['slice'](0x0,0x8)+_0x5428ea(0xf4)+this[_0x5428ea(0xf9)]+']\x20'+_0x4b788e);}async[a0_0x240860(0x110)](_0x1e3ef4,_0x5d3248){const _0xe8bd55=a0_0x240860;let _0x5154b4={'Content-Type':'application/json','Accept':_0xe8bd55(0x12d)};if(this[_0xe8bd55(0xf5)])_0x5154b4[_0xe8bd55(0x12f)]=_0xe8bd55(0x114)+this[_0xe8bd55(0xf5)];let _0x5e1651=await(await fetch(this[_0xe8bd55(0x13e)]+'/mcp',{'method':'POST','headers':_0x5154b4,'body':JSON['stringify']({'jsonrpc':_0xe8bd55(0x14f),'id':Date[_0xe8bd55(0xfc)](),'method':'tools/call','params':{'name':_0x1e3ef4,'arguments':_0x5d3248}})}))[_0xe8bd55(0x15b)](),_0x2a9e3e=_0x5e1651[_0xe8bd55(0xf1)](/data: (.+)/),_0x2a46f7=_0x2a9e3e?JSON[_0xe8bd55(0xfd)](_0x2a9e3e[0x1]):JSON[_0xe8bd55(0xfd)](_0x5e1651),_0x1b5d6e=_0x2a46f7?.['result']?.[_0xe8bd55(0xea)]?.[0x0]?.['text'];return _0x1b5d6e?JSON[_0xe8bd55(0xfd)](_0x1b5d6e):_0x2a46f7;}async[a0_0x240860(0x146)](){const _0x53d85d=a0_0x240860;if(this[_0x53d85d(0x145)])return;this[_0x53d85d(0x145)]=!0x0,await this[_0x53d85d(0x137)]('idle'),this['log'](_0x53d85d(0x11f)),this[_0x53d85d(0x115)]=setInterval(()=>{const _0x18ced7=_0x53d85d;this['status']('idle')['catch'](_0x5a727d=>this[_0x18ced7(0x113)](_0x18ced7(0x10f)+_0x5a727d[_0x18ced7(0xe9)]));},this[_0x53d85d(0x163)]),this[_0x53d85d(0x14c)]();}async[a0_0x240860(0xf2)](){const _0xa20671=a0_0x240860;if(this[_0xa20671(0x145)]=!0x1,this['sseAbort']?.[_0xa20671(0x15e)](),this['heartbeatTimer'])clearInterval(this[_0xa20671(0x115)]);await this[_0xa20671(0x137)]('offline')['catch'](()=>{}),this['log'](_0xa20671(0x152));}async[a0_0x240860(0x142)](_0x1df799,_0x2f4ba3,_0x35e566='normal'){const _0x583976=a0_0x240860;return u({'alias':_0x1df799,'fromAlias':this[_0x583976(0xf9)]},{'log':_0x4be846=>console[_0x583976(0x113)](_0x4be846),'send':()=>this[_0x583976(0x110)]('send_task',{'alias':_0x1df799,'task':_0x2f4ba3,'priority':_0x35e566,'from_session':this[_0x583976(0xf9)]})});}async[a0_0x240860(0xe9)](_0x47dfc0,_0x974a6c){const _0x34ed86=a0_0x240860;return this[_0x34ed86(0x110)](_0x34ed86(0x160),{'alias':_0x47dfc0,'message':_0x974a6c,'from_session':this[_0x34ed86(0xf9)]});}async['reply'](_0x153e61,_0x4ca25c,_0x3d1304=a0_0x240860(0xf3)){const _0x44489e=a0_0x240860;return this[_0x44489e(0x110)](_0x44489e(0x139),{'in_reply_to':_0x153e61,'text':_0x4ca25c,'status':_0x3d1304});}async[a0_0x240860(0x137)](_0x5e13a5,_0x5ebc83){const _0xf8a758=a0_0x240860;return this['call']('report_status',{'resume_id':this[_0xf8a758(0x11e)],'alias':this[_0xf8a758(0xf9)],'status':_0x5e13a5,'server':a0_0x11444b(),'hostname':a0_0x11444b(),'agent':this[_0xf8a758(0x13d)],'project_dir':process[_0xf8a758(0x151)](),..._0x5ebc83});}async[a0_0x240860(0x130)](){const _0x14c30d=a0_0x240860;return this[_0x14c30d(0x110)](_0x14c30d(0x10e),{});}async[a0_0x240860(0x157)](_0x36d094,_0x2e3e57){const _0x149bb8=a0_0x240860;return this[_0x149bb8(0x110)](_0x149bb8(0x157),{'message':_0x36d094,'filter_server':_0x2e3e57?.['server'],'filter_status':_0x2e3e57?.[_0x149bb8(0x137)]});}async['connectSSE'](){const _0x26ff5c=a0_0x240860;let _0x15c140=encodeURIComponent(this[_0x26ff5c(0xf9)]),_0x58c2b5=this['url']+_0x26ff5c(0x131)+_0x15c140,_0x30a412=this[_0x26ff5c(0x119)];while(this[_0x26ff5c(0x145)]){try{this[_0x26ff5c(0x13a)]=new AbortController();let _0x4e5ea9={'Accept':_0x26ff5c(0x147)};if(this[_0x26ff5c(0xf5)])_0x4e5ea9[_0x26ff5c(0x12f)]=_0x26ff5c(0x114)+this[_0x26ff5c(0xf5)];let _0x511bf7=await fetch(_0x58c2b5,{'headers':_0x4e5ea9,'signal':this[_0x26ff5c(0x13a)][_0x26ff5c(0xf0)]});if(!_0x511bf7['ok']||!_0x511bf7[_0x26ff5c(0x127)]){this[_0x26ff5c(0x113)](_0x26ff5c(0x158)+_0x511bf7[_0x26ff5c(0x137)]),await this['sleep'](_0x30a412),_0x30a412=Math[_0x26ff5c(0x12a)](_0x30a412*1.5,0xea60);continue;}_0x30a412=this['reconnectDelay'];let _0x38fecf=_0x511bf7[_0x26ff5c(0x127)][_0x26ff5c(0xfe)](),_0x2f9bfb=new TextDecoder(),_0x24607d='';while(this[_0x26ff5c(0x145)]){let {done:_0x1d6c6c,value:_0x26bf96}=await _0x38fecf[_0x26ff5c(0x116)]();if(_0x1d6c6c)break;_0x24607d+=_0x2f9bfb[_0x26ff5c(0x128)](_0x26bf96,{'stream':!0x0});let _0x37a360=_0x24607d[_0x26ff5c(0x161)]('\x0a');_0x24607d=_0x37a360[_0x26ff5c(0x15f)]()||'';for(let _0x48fdad of _0x37a360){if(!_0x48fdad['startsWith'](_0x26ff5c(0x13c)))continue;try{let _0x3cd990=JSON[_0x26ff5c(0xfd)](_0x48fdad[_0x26ff5c(0xeb)](0x6));if(_0x3cd990[_0x26ff5c(0x126)]==='connected'){this['log'](_0x26ff5c(0x13b)),this[_0x26ff5c(0x144)]('connected');continue;}if(_0x3cd990[_0x26ff5c(0x126)]===_0x26ff5c(0x11d)||_0x3cd990[_0x26ff5c(0x126)]===_0x26ff5c(0xec)||_0x3cd990[_0x26ff5c(0x126)]===_0x26ff5c(0x157))await this['processInbox']();}catch{}}}}catch(_0x4b0e70){if(_0x4b0e70[_0x26ff5c(0x12c)]===_0x26ff5c(0x133))break;this[_0x26ff5c(0x144)](_0x26ff5c(0x143),_0x4b0e70),this[_0x26ff5c(0x113)](_0x26ff5c(0x11b)+_0x4b0e70['message']);}if(this[_0x26ff5c(0x145)])this['emit'](_0x26ff5c(0x152)),this[_0x26ff5c(0x113)](_0x26ff5c(0xe8)+_0x30a412/0x3e8+_0x26ff5c(0x12b)),await this[_0x26ff5c(0xf8)](_0x30a412),_0x30a412=Math[_0x26ff5c(0x12a)](_0x30a412*1.5,0xea60);}}async['processInbox'](){const _0xae381d=a0_0x240860;try{let _0x12eb26=(await this['call'](_0xae381d(0x108),{'alias':this[_0xae381d(0xf9)],'limit':0xa}))?.[_0xae381d(0xff)]||[];for(let _0x12e458 of _0x12eb26)await this[_0xae381d(0x110)]('ack_inbox',{'alias':this[_0xae381d(0xf9)],'message_id':_0x12e458['id']}),this['log']('←\x20'+_0x12e458['from_session']+':\x20'+_0x12e458['content'][_0xae381d(0xeb)](0x0,0x3c)),this[_0xae381d(0x144)](_0xae381d(0x11c),_0x12e458),this[_0xae381d(0x144)]('message',_0x12e458);}catch(_0x4ab21f){this[_0xae381d(0x113)](_0xae381d(0x111)+_0x4ab21f[_0xae381d(0xe9)]);}}[a0_0x240860(0xf8)](_0x3f5ab1){return new Promise(_0x4560de=>setTimeout(_0x4560de,_0x3f5ab1));}}var O=k;export{k as CommHub,O as default};
1
+ const a0_0x1808a5=a0_0x51ca;(function(_0x4dbe43,_0x59b7ee){const _0x131f44=a0_0x51ca,_0x41c7f5=_0x4dbe43();while(!![]){try{const _0x5617a8=-parseInt(_0x131f44(0x178))/0x1+parseInt(_0x131f44(0x1b3))/0x2*(parseInt(_0x131f44(0x17f))/0x3)+-parseInt(_0x131f44(0x143))/0x4*(parseInt(_0x131f44(0x191))/0x5)+parseInt(_0x131f44(0x163))/0x6*(-parseInt(_0x131f44(0x186))/0x7)+-parseInt(_0x131f44(0x198))/0x8*(parseInt(_0x131f44(0x173))/0x9)+parseInt(_0x131f44(0x17e))/0xa+-parseInt(_0x131f44(0x166))/0xb*(-parseInt(_0x131f44(0x167))/0xc);if(_0x5617a8===_0x59b7ee)break;else _0x41c7f5['push'](_0x41c7f5['shift']());}catch(_0x36b2d9){_0x41c7f5['push'](_0x41c7f5['shift']());}}}(a0_0x14a5,0x40b72));import{EventEmitter as a0_0x269aca}from'events';function a0_0x51ca(_0xe64ce5,_0x14c7ae){_0xe64ce5=_0xe64ce5-0x140;const _0x14a51a=a0_0x14a5();let _0x51ca49=_0x14a51a[_0xe64ce5];return _0x51ca49;}import{hostname as a0_0x272304}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2ccd78,_0x553188)=>(_0x2ccd78??_0x553188)[a0_0x1808a5(0x16f)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x1808a5(0x14e)](0x0,0xf0);function N(_0x5e641d){const _0x270683=a0_0x1808a5;return(_0x5e641d instanceof Error?_0x5e641d[_0x270683(0x193)]:String(_0x5e641d??_0x270683(0x19b)))['replace'](K,_0x270683(0x165))[_0x270683(0x16f)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x477992,_0x5212f5=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x95230f=a0_0x1808a5;if(_0x5212f5)return JSON[_0x95230f(0x1bf)](_0x477992);let _0x3ee312=L(_0x477992[_0x95230f(0x17d)],_0x95230f(0x19d)),_0x20f16b=L(_0x477992[_0x95230f(0x177)],_0x95230f(0x18e)),_0x64106d=_0x477992[_0x95230f(0x14a)]?'\x20error='+_0x477992[_0x95230f(0x14a)]+':'+(_0x477992['error_message']??''):'';return _0x95230f(0x17b)+_0x477992[_0x95230f(0x16a)]+'\x20from='+L(_0x477992[_0x95230f(0x18d)],_0x95230f(0x1ab))+_0x95230f(0x18f)+L(_0x477992['to_alias'],'<unknown>')+_0x95230f(0x1a0)+_0x20f16b+'\x20parent_task_id='+_0x3ee312+_0x95230f(0x16d)+L(_0x477992[_0x95230f(0x192)],'<unknown>')+_0x95230f(0x140)+_0x477992[_0x95230f(0x158)]+'\x20duration_ms='+_0x477992['duration_ms']+_0x95230f(0x144)+_0x477992[_0x95230f(0x1ac)]+_0x64106d;}function a0_0x14a5(){const _0xd6f6f7=['running','30kPDdDk','processInbox','[REDACTED]','4193321zZylUf','12eqAHdq','task.send.start','task.send.failed','status','failed','messages','\x20network_id=','CommHub\x20response\x20omitted\x20task_id','replace','alias','application/json','normal','1372860kkUHIb','offline','2.0','idle','task_id','43065fEcQpz','min','catch','[commhub:task]\x20','reconnectDelay','parent_task_id','4354150NlOmGY','159RMfUyn','lifecycleTracking','url','parse','disconnected','connect','error','569905SkXVyX','resumeId','toString','not_tracked','/mcp','name','decode','from_alias','<pending>','\x20to=','content','145omwplW','network_id','message','tools/call','type','now','mcp_http','8lfxlXE','registered','pop','unknown\x20error','reply','<missing>','POST','task','\x20task_id=','ack_inbox','missing_task_id','get_inbox','result','send_message','delivered','connectSSE','SSE\x20failed:\x20','text/event-stream','heartbeat\x20failed:\x20','<unknown>','lifecycle_tracking','send_failed','sending','read','task.send.delivered','fromAlias','Authorization','7354eNMsZu','heartbeatInterval','sdk-','call','heartbeatTimer','log','autoConnect','s...','CommHub\x20rejected\x20task','data:\x20','toAlias','report_status','stringify','networkId','\x20transport=','send_rejected','new_task','19828EKLwxz','\x20lifecycle=','send','Bearer\x20','send_task','abort','from_session','error_code','emit','get_all_status','broadcast','slice','body','message_id','string',']\x20[commhub:','startsWith','new_message','token','application/json,\x20text/event-stream','getReader','transport','split','text','signal','SSE\x20connected','agent','sseAbort','parentTaskId','sleep','connected'];a0_0x14a5=function(){return _0xd6f6f7;};return a0_0x14a5();}function U(_0x2586c8){const _0x143e6=a0_0x1808a5;return{'event':{'sending':_0x143e6(0x168),'delivered':_0x143e6(0x1b0),'failed':_0x143e6(0x169),'acked':'task.ack','started':'task.started','replied':'task.replied','expired':'task.expired'}[_0x2586c8[_0x143e6(0x16a)]],..._0x2586c8};}function j(_0x141435){const _0xec007e=a0_0x1808a5;let _0x21a7da=_0x141435?.[_0xec007e(0x177)]||_0x141435?.[_0xec007e(0x150)]||_0x141435?.['id'];if(_0x21a7da)return String(_0x21a7da);let _0x25d748=_0x141435?.['content']?.[0x0]?.[_0xec007e(0x15a)];if(typeof _0x25d748!==_0xec007e(0x151))return null;try{let _0x5a0d2a=JSON[_0xec007e(0x182)](_0x25d748);return _0x5a0d2a?.[_0xec007e(0x177)]||_0x5a0d2a?.[_0xec007e(0x150)]||_0x5a0d2a?.['id']||null;}catch{return null;}}async function X(_0x2fda12,_0x16f46f){const _0x2bc7a1=a0_0x1808a5;let _0x17ee72=_0x16f46f[_0x2bc7a1(0x196)]??Date[_0x2bc7a1(0x196)],_0x15723a=_0x17ee72(),_0xe27869=(_0x29a5bb,_0x4cd7f1,_0x586eee,_0x1b4ddf)=>{const _0xbd962a=_0x2bc7a1;_0x16f46f[_0xbd962a(0x1b8)](O(U({'from_alias':_0x2fda12[_0xbd962a(0x1b1)],'to_alias':_0x2fda12[_0xbd962a(0x1bd)],'task_id':_0x4cd7f1,'parent_task_id':_0x2fda12[_0xbd962a(0x15f)],'network_id':_0x2fda12[_0xbd962a(0x1c0)],'transport':_0x2fda12[_0xbd962a(0x158)],'status':_0x29a5bb,'duration_ms':_0x17ee72()-_0x15723a,'lifecycle_tracking':_0x2fda12[_0xbd962a(0x180)],..._0x586eee!==void 0x0?{'error_code':_0x1b4ddf||'send_failed','error_message':N(_0x586eee)}:{}})));};_0xe27869(_0x2bc7a1(0x1ae),null);try{let _0xad09e2=await _0x16f46f[_0x2bc7a1(0x145)](),_0x2f611c=j(_0xad09e2);if(_0x2f611c)_0xe27869(_0x2bc7a1(0x1a6),_0x2f611c);else{if(_0xad09e2?.['ok']===!0x1||_0xad09e2?.[_0x2bc7a1(0x185)])_0xe27869('failed',_0x2f611c,_0xad09e2?.[_0x2bc7a1(0x185)]||_0x2bc7a1(0x1bb),_0x2bc7a1(0x141));else _0xe27869(_0x2bc7a1(0x16b),null,_0x2bc7a1(0x16e),_0x2bc7a1(0x1a2));}return _0xad09e2;}catch(_0x299b83){throw _0xe27869('failed',null,_0x299b83,_0x2bc7a1(0x1ad)),_0x299b83;}}async function Y(_0x5a4669,_0x88b723){const _0x2c627d=a0_0x1808a5;return X({'fromAlias':_0x5a4669[_0x2c627d(0x1b1)],'toAlias':_0x5a4669[_0x2c627d(0x170)],'parentTaskId':_0x5a4669[_0x2c627d(0x15f)]||null,'networkId':_0x5a4669[_0x2c627d(0x1c0)]||null,'transport':_0x2c627d(0x197),'lifecycleTracking':_0x2c627d(0x189)},_0x88b723);}class $ extends a0_0x269aca{[a0_0x1808a5(0x181)];['alias'];[a0_0x1808a5(0x155)];[a0_0x1808a5(0x15d)];[a0_0x1808a5(0x187)];[a0_0x1808a5(0x1b4)];['reconnectDelay'];[a0_0x1808a5(0x1b7)];['sseAbort'];[a0_0x1808a5(0x162)]=!0x1;constructor(_0x1614f0){const _0x40ffac=a0_0x1808a5;super();if(this['url']=_0x1614f0['url'][_0x40ffac(0x16f)](/\/$/,''),this[_0x40ffac(0x170)]=_0x1614f0[_0x40ffac(0x170)],this[_0x40ffac(0x155)]=_0x1614f0[_0x40ffac(0x155)],this[_0x40ffac(0x15d)]=_0x1614f0['agent']||'sdk',this[_0x40ffac(0x187)]=_0x40ffac(0x1b5)+_0x1614f0[_0x40ffac(0x170)]+'-'+Date[_0x40ffac(0x196)]()[_0x40ffac(0x188)](0x24),this['heartbeatInterval']=_0x1614f0['heartbeatInterval']??0x2bf20,this[_0x40ffac(0x17c)]=_0x1614f0['reconnectDelay']??0xbb8,_0x1614f0[_0x40ffac(0x1b9)]!==!0x1)this[_0x40ffac(0x184)]();}[a0_0x1808a5(0x1b8)](_0x5ec3ca){const _0x53ae7b=a0_0x1808a5;console[_0x53ae7b(0x1b8)]('['+new Date()['toTimeString']()[_0x53ae7b(0x14e)](0x0,0x8)+_0x53ae7b(0x152)+this[_0x53ae7b(0x170)]+']\x20'+_0x5ec3ca);}async['call'](_0x354da1,_0x36fe55){const _0x448280=a0_0x1808a5;let _0x515e09={'Content-Type':_0x448280(0x171),'Accept':_0x448280(0x156)};if(this[_0x448280(0x155)])_0x515e09['Authorization']=_0x448280(0x146)+this['token'];let _0x9c46e0=await(await fetch(this[_0x448280(0x181)]+_0x448280(0x18a),{'method':_0x448280(0x19e),'headers':_0x515e09,'body':JSON['stringify']({'jsonrpc':_0x448280(0x175),'id':Date[_0x448280(0x196)](),'method':_0x448280(0x194),'params':{'name':_0x354da1,'arguments':_0x36fe55}})}))[_0x448280(0x15a)](),_0xdb07fc=_0x9c46e0['match'](/data: (.+)/),_0x2f3765=_0xdb07fc?JSON['parse'](_0xdb07fc[0x1]):JSON[_0x448280(0x182)](_0x9c46e0),_0x402853=_0x2f3765?.[_0x448280(0x1a4)]?.[_0x448280(0x190)]?.[0x0]?.[_0x448280(0x15a)];return _0x402853?JSON[_0x448280(0x182)](_0x402853):_0x2f3765;}async['connect'](){const _0x3c999f=a0_0x1808a5;if(this[_0x3c999f(0x162)])return;this[_0x3c999f(0x162)]=!0x0,await this[_0x3c999f(0x16a)](_0x3c999f(0x176)),this[_0x3c999f(0x1b8)](_0x3c999f(0x199)),this['heartbeatTimer']=setInterval(()=>{const _0x28943f=_0x3c999f;this[_0x28943f(0x16a)](_0x28943f(0x176))[_0x28943f(0x17a)](_0x155200=>this[_0x28943f(0x1b8)](_0x28943f(0x1aa)+_0x155200[_0x28943f(0x193)]));},this[_0x3c999f(0x1b4)]),this[_0x3c999f(0x1a7)]();}async['disconnect'](){const _0x3dd5ba=a0_0x1808a5;if(this['running']=!0x1,this[_0x3dd5ba(0x15e)]?.[_0x3dd5ba(0x148)](),this[_0x3dd5ba(0x1b7)])clearInterval(this[_0x3dd5ba(0x1b7)]);await this['status'](_0x3dd5ba(0x174))[_0x3dd5ba(0x17a)](()=>{}),this['log'](_0x3dd5ba(0x183));}async[a0_0x1808a5(0x145)](_0x5916bd,_0x216cef,_0x308d88=a0_0x1808a5(0x172)){const _0x313256=a0_0x1808a5;return Y({'alias':_0x5916bd,'fromAlias':this[_0x313256(0x170)]},{'log':_0x4ff3d6=>console['log'](_0x4ff3d6),'send':()=>this[_0x313256(0x1b6)](_0x313256(0x147),{'alias':_0x5916bd,'task':_0x216cef,'priority':_0x308d88,'from_session':this['alias']})});}async['message'](_0x5de8c1,_0x12221a){const _0x38eecb=a0_0x1808a5;return this[_0x38eecb(0x1b6)](_0x38eecb(0x1a5),{'alias':_0x5de8c1,'message':_0x12221a,'from_session':this[_0x38eecb(0x170)]});}async[a0_0x1808a5(0x19c)](_0x20eea6,_0x43ff2c,_0xa52fc7='completed'){const _0x10846e=a0_0x1808a5;return this[_0x10846e(0x1b6)]('send_reply',{'in_reply_to':_0x20eea6,'text':_0x43ff2c,'status':_0xa52fc7});}async['status'](_0x294de0,_0x469955){const _0x2a37d1=a0_0x1808a5;return this['call'](_0x2a37d1(0x1be),{'resume_id':this[_0x2a37d1(0x187)],'alias':this[_0x2a37d1(0x170)],'status':_0x294de0,'server':a0_0x272304(),'hostname':a0_0x272304(),'agent':this[_0x2a37d1(0x15d)],'project_dir':process['cwd'](),..._0x469955});}async['getAllStatus'](){const _0x2f219a=a0_0x1808a5;return this['call'](_0x2f219a(0x14c),{});}async[a0_0x1808a5(0x14d)](_0xf592a6,_0x4bbca5){const _0x31945e=a0_0x1808a5;return this[_0x31945e(0x1b6)](_0x31945e(0x14d),{'message':_0xf592a6,'filter_server':_0x4bbca5?.['server'],'filter_status':_0x4bbca5?.[_0x31945e(0x16a)]});}async[a0_0x1808a5(0x1a7)](){const _0x42d796=a0_0x1808a5;let _0x4be0eb=encodeURIComponent(this['alias']),_0x2f629e=this['url']+'/events/'+_0x4be0eb,_0x5f0b0e=this['reconnectDelay'];while(this[_0x42d796(0x162)]){try{this[_0x42d796(0x15e)]=new AbortController();let _0x210d7a={'Accept':_0x42d796(0x1a9)};if(this['token'])_0x210d7a[_0x42d796(0x1b2)]='Bearer\x20'+this[_0x42d796(0x155)];let _0x5c75be=await fetch(_0x2f629e,{'headers':_0x210d7a,'signal':this[_0x42d796(0x15e)][_0x42d796(0x15b)]});if(!_0x5c75be['ok']||!_0x5c75be[_0x42d796(0x14f)]){this['log'](_0x42d796(0x1a8)+_0x5c75be[_0x42d796(0x16a)]),await this[_0x42d796(0x160)](_0x5f0b0e),_0x5f0b0e=Math[_0x42d796(0x179)](_0x5f0b0e*1.5,0xea60);continue;}_0x5f0b0e=this[_0x42d796(0x17c)];let _0x1fa8fc=_0x5c75be[_0x42d796(0x14f)][_0x42d796(0x157)](),_0x5c3350=new TextDecoder(),_0x40c11c='';while(this['running']){let {done:_0x50ba14,value:_0x311a32}=await _0x1fa8fc[_0x42d796(0x1af)]();if(_0x50ba14)break;_0x40c11c+=_0x5c3350[_0x42d796(0x18c)](_0x311a32,{'stream':!0x0});let _0x53b002=_0x40c11c[_0x42d796(0x159)]('\x0a');_0x40c11c=_0x53b002[_0x42d796(0x19a)]()||'';for(let _0xd345d of _0x53b002){if(!_0xd345d[_0x42d796(0x153)](_0x42d796(0x1bc)))continue;try{let _0x43c19d=JSON['parse'](_0xd345d[_0x42d796(0x14e)](0x6));if(_0x43c19d[_0x42d796(0x195)]===_0x42d796(0x161)){this[_0x42d796(0x1b8)](_0x42d796(0x15c)),this[_0x42d796(0x14b)]('connected');continue;}if(_0x43c19d[_0x42d796(0x195)]===_0x42d796(0x142)||_0x43c19d[_0x42d796(0x195)]===_0x42d796(0x154)||_0x43c19d[_0x42d796(0x195)]===_0x42d796(0x14d))await this[_0x42d796(0x164)]();}catch{}}}}catch(_0x507283){if(_0x507283[_0x42d796(0x18b)]==='AbortError')break;this['emit'](_0x42d796(0x185),_0x507283),this[_0x42d796(0x1b8)]('SSE\x20error:\x20'+_0x507283['message']);}if(this['running'])this[_0x42d796(0x14b)](_0x42d796(0x183)),this[_0x42d796(0x1b8)]('SSE\x20reconnecting\x20in\x20'+_0x5f0b0e/0x3e8+_0x42d796(0x1ba)),await this['sleep'](_0x5f0b0e),_0x5f0b0e=Math['min'](_0x5f0b0e*1.5,0xea60);}}async[a0_0x1808a5(0x164)](){const _0x59d40b=a0_0x1808a5;try{let _0x2fe330=(await this[_0x59d40b(0x1b6)](_0x59d40b(0x1a3),{'alias':this[_0x59d40b(0x170)],'limit':0xa}))?.[_0x59d40b(0x16c)]||[];for(let _0x19bc47 of _0x2fe330)await this[_0x59d40b(0x1b6)](_0x59d40b(0x1a1),{'alias':this['alias'],'message_id':_0x19bc47['id']}),this[_0x59d40b(0x1b8)]('←\x20'+_0x19bc47[_0x59d40b(0x149)]+':\x20'+_0x19bc47[_0x59d40b(0x190)]['slice'](0x0,0x3c)),this[_0x59d40b(0x14b)](_0x59d40b(0x19f),_0x19bc47),this[_0x59d40b(0x14b)](_0x59d40b(0x193),_0x19bc47);}catch(_0x1fdedd){this[_0x59d40b(0x1b8)]('inbox\x20error:\x20'+_0x1fdedd[_0x59d40b(0x193)]);}}[a0_0x1808a5(0x160)](_0x49d098){return new Promise(_0x1bda73=>setTimeout(_0x1bda73,_0x49d098));}}var F=$;export{F as default,$ as CommHub};
@@ -29,8 +29,29 @@
29
29
  * M4: agent-node spawn integration (fork(this) wired by agent-node).
30
30
  * M5: group @bot trigger refinement, image up/down, Docker smoke.
31
31
  */
32
- import type { NormalizedIMEvent } from "../types.js";
32
+ import type { IMCorrelationStore, NormalizedIMEvent } from "../types.js";
33
33
  import { FeishuAdapter } from "./adapter.js";
34
+ export type IMBridgeCommHubInboxMessage = {
35
+ id: string;
36
+ type?: string;
37
+ content: string;
38
+ from_session?: string;
39
+ in_reply_to?: string;
40
+ meta?: unknown;
41
+ };
42
+ export interface IMBridgeCommHubClient {
43
+ sendTask(args: {
44
+ alias: string;
45
+ task: string;
46
+ priority?: "high" | "normal" | "low";
47
+ ttlSeconds?: number;
48
+ meta?: unknown;
49
+ }): Promise<{
50
+ taskId: string;
51
+ }>;
52
+ getInbox(alias: string): Promise<IMBridgeCommHubInboxMessage[]>;
53
+ ackInbox(alias: string, messageId: string): Promise<void>;
54
+ }
34
55
  export interface FeishuBridgeOptions {
35
56
  /** Absolute path to `.anet/nodes/<node>/channels/feishu/`. */
36
57
  channelDir: string;
@@ -46,6 +67,12 @@ export interface FeishuBridgeOptions {
46
67
  onEvent?: (event: NormalizedIMEvent) => Promise<void>;
47
68
  /** Fatal WS failure after initial readiness (for worker lifecycle ownership). */
48
69
  onTerminalError?: (error: Error) => void;
70
+ /** Persistent task/message correlation state. Defaults to channelDir/state.json. */
71
+ correlationStore?: IMCorrelationStore;
72
+ /** CommHub task transport. Defaults to COMMHUB_URL/COMMHUB_TOKEN when available. */
73
+ commhubClient?: IMBridgeCommHubClient;
74
+ /** Poll interval for CommHub replies. Defaults to 1500ms. */
75
+ commhubPollMs?: number;
49
76
  }
50
77
  /** Bridge → parent: inbound IM event ready for think(). */
51
78
  export interface BridgeIncomingEnvelope {
@@ -127,7 +154,8 @@ export type WithRateLimitHandle = {
127
154
  * the agent-node.log (closes the prior silent-success blindspot).
128
155
  */
129
156
  /** @internal exported for test harness; not intended for production callers. */
130
- export declare function createIPCEventHandler(adapter: FeishuAdapter, ttlMs: number, ackPlaceholder: boolean): (event: NormalizedIMEvent) => Promise<void>;
157
+ export declare function createIPCEventHandler(adapter: FeishuAdapter, ttlMs: number, ackPlaceholder: boolean, correlationStore?: IMCorrelationStore): (event: NormalizedIMEvent) => Promise<void>;
158
+ export declare function createCommHubEventHandler(nodeAlias: string, adapter: FeishuAdapter, ttlMs: number, ackPlaceholder: boolean, correlationStore: IMCorrelationStore | undefined, commhubClient: IMBridgeCommHubClient, pollMs?: number): (event: NormalizedIMEvent) => Promise<void>;
131
159
  export { FeishuAdapter } from "./adapter.js";
132
160
  export { loadFeishuChannelConfig } from "./config.js";
133
161
  export type { FeishuAccessList, FeishuChannelConfig, FeishuChannelEnv, } from "./config.js";