@sleep2agi/agent-network 2.3.0-preview.110 → 2.3.0-preview.112

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_0x299df7=a0_0x1702;(function(_0x3c2861,_0x2ece58){const _0xc758b8=a0_0x1702,_0x32f1e7=_0x3c2861();while(!![]){try{const _0x897b03=-parseInt(_0xc758b8(0x1d1))/0x1*(-parseInt(_0xc758b8(0x1b8))/0x2)+-parseInt(_0xc758b8(0x198))/0x3+parseInt(_0xc758b8(0x1bd))/0x4*(parseInt(_0xc758b8(0x1db))/0x5)+-parseInt(_0xc758b8(0x1c4))/0x6+parseInt(_0xc758b8(0x194))/0x7+-parseInt(_0xc758b8(0x1a2))/0x8*(-parseInt(_0xc758b8(0x1eb))/0x9)+-parseInt(_0xc758b8(0x18b))/0xa*(parseInt(_0xc758b8(0x199))/0xb);if(_0x897b03===_0x2ece58)break;else _0x32f1e7['push'](_0x32f1e7['shift']());}catch(_0x5194b7){_0x32f1e7['push'](_0x32f1e7['shift']());}}}(a0_0x2af0,0xb1cf2));import{EventEmitter as a0_0x243591}from'events';import{hostname as a0_0x29b66a}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x412db3,_0xdc3f)=>(_0x412db3??_0xdc3f)[a0_0x299df7(0x1b1)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x299df7(0x1ff)](0x0,0xf0);function N(_0x1e1dc4){const _0x37cffa=a0_0x299df7;return(_0x1e1dc4 instanceof Error?_0x1e1dc4[_0x37cffa(0x1a7)]:String(_0x1e1dc4??'unknown\x20error'))[_0x37cffa(0x1b1)](K,'[REDACTED]')['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x37cffa(0x1ff)](0x0,0xf0);}function a0_0x2af0(){const _0x1be8a8=['SSE\x20failed:\x20','getAllStatus','parse','reply','startsWith','<missing>','error_code','network_id','type','toString','connect','sending','min','474120PttKzj','from_alias','report_status','failed','Bearer\x20','\x20transport=','stringify','send_reply','<pending>','fromAlias','to_alias','call','getReader','match','error','abort','url','send_task','sdk-','2.0','slice','\x20duration_ms=','inbox\x20error:\x20','application/json','duration_ms','data:\x20','\x20from=','task.started','47810vVpceb','idle','parentTaskId','status','SSE\x20reconnecting\x20in\x20','lifecycleTracking','connectSSE','running','reconnectDelay','6753355ktAjIL','text','message_id','send_rejected','1360965AaDQEq','2167nXQakN','cwd','disconnected','get_all_status','emit',']\x20[commhub:','processInbox','networkId','catch','32pGIQHp','now','agent','[commhub:task]\x20','json','message','log','sleep','heartbeatTimer','heartbeatInterval','pop','\x20error=','not_tracked','delivered','tools/call','replace','parent_task_id','text/event-stream','CommHub\x20response\x20omitted\x20task_id','sseAbort','send','connected','3826ajLoWa','Authorization','task.send.failed','mcp_http','new_message','8iirrEE','content','/mcp','s...','broadcast','token','POST','3166188GeCsbE','transport','ack_inbox','decode','task.replied','\x20network_id=','<unknown>','normal','signal','task.expired','application/json,\x20text/event-stream','task_id','from_session','73vmhcGp','body','heartbeat\x20failed:\x20','alias','SSE\x20error:\x20','resumeId','send_failed','task.send.start','new_task','read','3340955CtXfGp','toTimeString','\x20lifecycle='];a0_0x2af0=function(){return _0x1be8a8;};return a0_0x2af0();}function O(_0x2979fe,_0x5e97c0=process.env.ANET_TASK_TRACE_FORMAT===a0_0x299df7(0x1a6)){const _0xe754fc=a0_0x299df7;if(_0x5e97c0)return JSON[_0xe754fc(0x1f1)](_0x2979fe);let _0x1075ed=L(_0x2979fe[_0xe754fc(0x1b2)],_0xe754fc(0x1e3)),_0x4b31b8=L(_0x2979fe['task_id'],_0xe754fc(0x1f3)),_0x4489f5=_0x2979fe[_0xe754fc(0x1e4)]?_0xe754fc(0x1ad)+_0x2979fe[_0xe754fc(0x1e4)]+':'+(_0x2979fe['error_message']??''):'';return _0xe754fc(0x1a5)+_0x2979fe[_0xe754fc(0x18e)]+_0xe754fc(0x189)+L(_0x2979fe[_0xe754fc(0x1ec)],_0xe754fc(0x1ca))+'\x20to='+L(_0x2979fe[_0xe754fc(0x1f5)],_0xe754fc(0x1ca))+'\x20task_id='+_0x4b31b8+'\x20parent_task_id='+_0x1075ed+_0xe754fc(0x1c9)+L(_0x2979fe[_0xe754fc(0x1e5)],_0xe754fc(0x1ca))+_0xe754fc(0x1f0)+_0x2979fe[_0xe754fc(0x1c5)]+_0xe754fc(0x200)+_0x2979fe[_0xe754fc(0x187)]+_0xe754fc(0x1dd)+_0x2979fe['lifecycle_tracking']+_0x4489f5;}function U(_0x11919c){const _0x1cfabe=a0_0x299df7;return{'event':{'sending':_0x1cfabe(0x1d8),'delivered':'task.send.delivered','failed':_0x1cfabe(0x1ba),'acked':'task.ack','started':_0x1cfabe(0x18a),'replied':_0x1cfabe(0x1c8),'expired':_0x1cfabe(0x1cd)}[_0x11919c[_0x1cfabe(0x18e)]],..._0x11919c};}function j(_0x2162cf){const _0x369abc=a0_0x299df7;let _0x293409=_0x2162cf?.[_0x369abc(0x1cf)]||_0x2162cf?.['message_id']||_0x2162cf?.['id'];if(_0x293409)return String(_0x293409);let _0x4b3c43=_0x2162cf?.[_0x369abc(0x1be)]?.[0x0]?.[_0x369abc(0x195)];if(typeof _0x4b3c43!=='string')return null;try{let _0x319218=JSON[_0x369abc(0x1e0)](_0x4b3c43);return _0x319218?.[_0x369abc(0x1cf)]||_0x319218?.[_0x369abc(0x196)]||_0x319218?.['id']||null;}catch{return null;}}async function X(_0x2d0768,_0xfc4e68){const _0x2931eb=a0_0x299df7;let _0x2abfd4=_0xfc4e68[_0x2931eb(0x1a3)]??Date['now'],_0x24272d=_0x2abfd4(),_0x4a6715=(_0x5ee53f,_0x23c4e3,_0x1ad9b3,_0x34ad5a)=>{const _0x45f006=_0x2931eb;_0xfc4e68[_0x45f006(0x1a8)](O(U({'from_alias':_0x2d0768['fromAlias'],'to_alias':_0x2d0768['toAlias'],'task_id':_0x23c4e3,'parent_task_id':_0x2d0768[_0x45f006(0x18d)],'network_id':_0x2d0768[_0x45f006(0x1a0)],'transport':_0x2d0768[_0x45f006(0x1c5)],'status':_0x5ee53f,'duration_ms':_0x2abfd4()-_0x24272d,'lifecycle_tracking':_0x2d0768[_0x45f006(0x190)],..._0x1ad9b3!==void 0x0?{'error_code':_0x34ad5a||'send_failed','error_message':N(_0x1ad9b3)}:{}})));};_0x4a6715(_0x2931eb(0x1e9),null);try{let _0x3d2bb6=await _0xfc4e68[_0x2931eb(0x1b6)](),_0xaa36a4=j(_0x3d2bb6);if(_0xaa36a4)_0x4a6715(_0x2931eb(0x1af),_0xaa36a4);else{if(_0x3d2bb6?.['ok']===!0x1||_0x3d2bb6?.[_0x2931eb(0x1f9)])_0x4a6715(_0x2931eb(0x1ee),_0xaa36a4,_0x3d2bb6?.[_0x2931eb(0x1f9)]||'CommHub\x20rejected\x20task',_0x2931eb(0x197));else _0x4a6715(_0x2931eb(0x1ee),null,_0x2931eb(0x1b4),'missing_task_id');}return _0x3d2bb6;}catch(_0x535214){throw _0x4a6715(_0x2931eb(0x1ee),null,_0x535214,_0x2931eb(0x1d7)),_0x535214;}}async function Y(_0x8441f8,_0x205aa3){const _0x262aa1=a0_0x299df7;return X({'fromAlias':_0x8441f8[_0x262aa1(0x1f4)],'toAlias':_0x8441f8[_0x262aa1(0x1d4)],'parentTaskId':_0x8441f8[_0x262aa1(0x18d)]||null,'networkId':_0x8441f8['networkId']||null,'transport':_0x262aa1(0x1bb),'lifecycleTracking':_0x262aa1(0x1ae)},_0x205aa3);}function a0_0x1702(_0x3fa9a6,_0x4cdf26){_0x3fa9a6=_0x3fa9a6-0x185;const _0x2af0de=a0_0x2af0();let _0x1702f1=_0x2af0de[_0x3fa9a6];return _0x1702f1;}class $ extends a0_0x243591{['url'];['alias'];[a0_0x299df7(0x1c2)];[a0_0x299df7(0x1a4)];[a0_0x299df7(0x1d6)];[a0_0x299df7(0x1ab)];['reconnectDelay'];[a0_0x299df7(0x1aa)];[a0_0x299df7(0x1b5)];['running']=!0x1;constructor(_0x22b9dc){const _0x31ff1c=a0_0x299df7;super();if(this['url']=_0x22b9dc['url'][_0x31ff1c(0x1b1)](/\/$/,''),this['alias']=_0x22b9dc[_0x31ff1c(0x1d4)],this[_0x31ff1c(0x1c2)]=_0x22b9dc['token'],this['agent']=_0x22b9dc[_0x31ff1c(0x1a4)]||'sdk',this[_0x31ff1c(0x1d6)]=_0x31ff1c(0x1fd)+_0x22b9dc[_0x31ff1c(0x1d4)]+'-'+Date[_0x31ff1c(0x1a3)]()[_0x31ff1c(0x1e7)](0x24),this['heartbeatInterval']=_0x22b9dc[_0x31ff1c(0x1ab)]??0x2bf20,this[_0x31ff1c(0x193)]=_0x22b9dc[_0x31ff1c(0x193)]??0xbb8,_0x22b9dc['autoConnect']!==!0x1)this[_0x31ff1c(0x1e8)]();}['log'](_0x2878da){const _0x3dbbcf=a0_0x299df7;console['log']('['+new Date()[_0x3dbbcf(0x1dc)]()['slice'](0x0,0x8)+_0x3dbbcf(0x19e)+this['alias']+']\x20'+_0x2878da);}async[a0_0x299df7(0x1f6)](_0x5435ec,_0x260c01){const _0x42f2c8=a0_0x299df7;let _0x4d8388={'Content-Type':_0x42f2c8(0x186),'Accept':_0x42f2c8(0x1ce)};if(this['token'])_0x4d8388[_0x42f2c8(0x1b9)]='Bearer\x20'+this['token'];let _0xb7c83d=await(await fetch(this[_0x42f2c8(0x1fb)]+_0x42f2c8(0x1bf),{'method':_0x42f2c8(0x1c3),'headers':_0x4d8388,'body':JSON[_0x42f2c8(0x1f1)]({'jsonrpc':_0x42f2c8(0x1fe),'id':Date[_0x42f2c8(0x1a3)](),'method':_0x42f2c8(0x1b0),'params':{'name':_0x5435ec,'arguments':_0x260c01}})}))['text'](),_0x5f5c36=_0xb7c83d[_0x42f2c8(0x1f8)](/data: (.+)/),_0x25a33c=_0x5f5c36?JSON[_0x42f2c8(0x1e0)](_0x5f5c36[0x1]):JSON['parse'](_0xb7c83d),_0x523a6b=_0x25a33c?.['result']?.[_0x42f2c8(0x1be)]?.[0x0]?.['text'];return _0x523a6b?JSON[_0x42f2c8(0x1e0)](_0x523a6b):_0x25a33c;}async[a0_0x299df7(0x1e8)](){const _0x39682b=a0_0x299df7;if(this[_0x39682b(0x192)])return;this[_0x39682b(0x192)]=!0x0,await this['status']('idle'),this[_0x39682b(0x1a8)]('registered'),this[_0x39682b(0x1aa)]=setInterval(()=>{const _0x3fae7d=_0x39682b;this[_0x3fae7d(0x18e)](_0x3fae7d(0x18c))[_0x3fae7d(0x1a1)](_0x36515e=>this[_0x3fae7d(0x1a8)](_0x3fae7d(0x1d3)+_0x36515e[_0x3fae7d(0x1a7)]));},this['heartbeatInterval']),this[_0x39682b(0x191)]();}async['disconnect'](){const _0xc6488d=a0_0x299df7;if(this[_0xc6488d(0x192)]=!0x1,this['sseAbort']?.[_0xc6488d(0x1fa)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0xc6488d(0x18e)]('offline')[_0xc6488d(0x1a1)](()=>{}),this[_0xc6488d(0x1a8)](_0xc6488d(0x19b));}async[a0_0x299df7(0x1b6)](_0x5acb85,_0x41459f,_0x50dcc4=a0_0x299df7(0x1cb)){const _0x476d58=a0_0x299df7;return Y({'alias':_0x5acb85,'fromAlias':this[_0x476d58(0x1d4)]},{'log':_0x4505c9=>console['log'](_0x4505c9),'send':()=>this[_0x476d58(0x1f6)](_0x476d58(0x1fc),{'alias':_0x5acb85,'task':_0x41459f,'priority':_0x50dcc4,'from_session':this[_0x476d58(0x1d4)]})});}async['message'](_0x31cf67,_0x4f536d){const _0x521b86=a0_0x299df7;return this[_0x521b86(0x1f6)]('send_message',{'alias':_0x31cf67,'message':_0x4f536d,'from_session':this[_0x521b86(0x1d4)]});}async[a0_0x299df7(0x1e1)](_0x49fa7d,_0x5d1047,_0x991c81='completed'){const _0x50ccf2=a0_0x299df7;return this[_0x50ccf2(0x1f6)](_0x50ccf2(0x1f2),{'in_reply_to':_0x49fa7d,'text':_0x5d1047,'status':_0x991c81});}async[a0_0x299df7(0x18e)](_0x3953cc,_0x3bb175){const _0x30b470=a0_0x299df7;return this[_0x30b470(0x1f6)](_0x30b470(0x1ed),{'resume_id':this[_0x30b470(0x1d6)],'alias':this[_0x30b470(0x1d4)],'status':_0x3953cc,'server':a0_0x29b66a(),'hostname':a0_0x29b66a(),'agent':this['agent'],'project_dir':process[_0x30b470(0x19a)](),..._0x3bb175});}async[a0_0x299df7(0x1df)](){const _0x858caa=a0_0x299df7;return this[_0x858caa(0x1f6)](_0x858caa(0x19c),{});}async[a0_0x299df7(0x1c1)](_0x5b2edc,_0x41e67d){const _0x514c6d=a0_0x299df7;return this[_0x514c6d(0x1f6)](_0x514c6d(0x1c1),{'message':_0x5b2edc,'filter_server':_0x41e67d?.['server'],'filter_status':_0x41e67d?.['status']});}async[a0_0x299df7(0x191)](){const _0x497b93=a0_0x299df7;let _0x2386ef=encodeURIComponent(this['alias']),_0x4001d5=this['url']+'/events/'+_0x2386ef,_0x1b2390=this[_0x497b93(0x193)];while(this[_0x497b93(0x192)]){try{this[_0x497b93(0x1b5)]=new AbortController();let _0x17fc99={'Accept':_0x497b93(0x1b3)};if(this[_0x497b93(0x1c2)])_0x17fc99[_0x497b93(0x1b9)]=_0x497b93(0x1ef)+this[_0x497b93(0x1c2)];let _0x4ef46d=await fetch(_0x4001d5,{'headers':_0x17fc99,'signal':this['sseAbort'][_0x497b93(0x1cc)]});if(!_0x4ef46d['ok']||!_0x4ef46d[_0x497b93(0x1d2)]){this['log'](_0x497b93(0x1de)+_0x4ef46d[_0x497b93(0x18e)]),await this[_0x497b93(0x1a9)](_0x1b2390),_0x1b2390=Math['min'](_0x1b2390*1.5,0xea60);continue;}_0x1b2390=this['reconnectDelay'];let _0x253f76=_0x4ef46d['body'][_0x497b93(0x1f7)](),_0x53e39b=new TextDecoder(),_0x464446='';while(this[_0x497b93(0x192)]){let {done:_0x39afc2,value:_0x523d91}=await _0x253f76[_0x497b93(0x1da)]();if(_0x39afc2)break;_0x464446+=_0x53e39b[_0x497b93(0x1c7)](_0x523d91,{'stream':!0x0});let _0x3bd7b2=_0x464446['split']('\x0a');_0x464446=_0x3bd7b2[_0x497b93(0x1ac)]()||'';for(let _0x20bc34 of _0x3bd7b2){if(!_0x20bc34[_0x497b93(0x1e2)](_0x497b93(0x188)))continue;try{let _0x97957=JSON['parse'](_0x20bc34[_0x497b93(0x1ff)](0x6));if(_0x97957[_0x497b93(0x1e6)]===_0x497b93(0x1b7)){this[_0x497b93(0x1a8)]('SSE\x20connected'),this[_0x497b93(0x19d)](_0x497b93(0x1b7));continue;}if(_0x97957['type']===_0x497b93(0x1d9)||_0x97957[_0x497b93(0x1e6)]===_0x497b93(0x1bc)||_0x97957[_0x497b93(0x1e6)]===_0x497b93(0x1c1))await this[_0x497b93(0x19f)]();}catch{}}}}catch(_0x4f6052){if(_0x4f6052['name']==='AbortError')break;this[_0x497b93(0x19d)](_0x497b93(0x1f9),_0x4f6052),this[_0x497b93(0x1a8)](_0x497b93(0x1d5)+_0x4f6052[_0x497b93(0x1a7)]);}if(this[_0x497b93(0x192)])this[_0x497b93(0x19d)]('disconnected'),this[_0x497b93(0x1a8)](_0x497b93(0x18f)+_0x1b2390/0x3e8+_0x497b93(0x1c0)),await this[_0x497b93(0x1a9)](_0x1b2390),_0x1b2390=Math[_0x497b93(0x1ea)](_0x1b2390*1.5,0xea60);}}async[a0_0x299df7(0x19f)](){const _0x1ae8f4=a0_0x299df7;try{let _0xe0c788=(await this['call']('get_inbox',{'alias':this[_0x1ae8f4(0x1d4)],'limit':0xa}))?.['messages']||[];for(let _0x5ef687 of _0xe0c788)await this[_0x1ae8f4(0x1f6)](_0x1ae8f4(0x1c6),{'alias':this['alias'],'message_id':_0x5ef687['id']}),this[_0x1ae8f4(0x1a8)]('←\x20'+_0x5ef687[_0x1ae8f4(0x1d0)]+':\x20'+_0x5ef687['content'][_0x1ae8f4(0x1ff)](0x0,0x3c)),this['emit']('task',_0x5ef687),this['emit']('message',_0x5ef687);}catch(_0x5c76b9){this[_0x1ae8f4(0x1a8)](_0x1ae8f4(0x185)+_0x5c76b9[_0x1ae8f4(0x1a7)]);}}[a0_0x299df7(0x1a9)](_0x4bbc6d){return new Promise(_0x250412=>setTimeout(_0x250412,_0x4bbc6d));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x2c6390=a0_0x54aa;(function(_0x2e0c12,_0xe55294){const _0x44a09d=a0_0x54aa,_0x48f334=_0x2e0c12();while(!![]){try{const _0x1a86f4=parseInt(_0x44a09d(0x11f))/0x1+parseInt(_0x44a09d(0x121))/0x2*(-parseInt(_0x44a09d(0xbd))/0x3)+-parseInt(_0x44a09d(0x115))/0x4*(parseInt(_0x44a09d(0xef))/0x5)+parseInt(_0x44a09d(0xe4))/0x6+parseInt(_0x44a09d(0x12d))/0x7+-parseInt(_0x44a09d(0xc3))/0x8*(-parseInt(_0x44a09d(0xe0))/0x9)+-parseInt(_0x44a09d(0xf6))/0xa;if(_0x1a86f4===_0xe55294)break;else _0x48f334['push'](_0x48f334['shift']());}catch(_0xbefd82){_0x48f334['push'](_0x48f334['shift']());}}}(a0_0x3da2,0xee530));function a0_0x54aa(_0x2c36ef,_0x2c07cc){_0x2c36ef=_0x2c36ef-0xba;const _0x3da2b5=a0_0x3da2();let _0x54aa02=_0x3da2b5[_0x2c36ef];return _0x54aa02;}import{EventEmitter as a0_0xae0a67}from'events';import{hostname as a0_0x5b0365}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2a4beb,_0x22043f)=>(_0x2a4beb??_0x22043f)[a0_0x2c6390(0x126)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x2c6390(0xdf)](0x0,0xf0);function N(_0x57474c){const _0x3f5df7=a0_0x2c6390;return(_0x57474c instanceof Error?_0x57474c['message']:String(_0x57474c??_0x3f5df7(0x137)))[_0x3f5df7(0x126)](K,_0x3f5df7(0x130))[_0x3f5df7(0x126)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x3f5df7(0xdf)](0x0,0xf0);}function O(_0x52d5e4,_0x1d26f7=process.env.ANET_TASK_TRACE_FORMAT===a0_0x2c6390(0xc2)){const _0x3efd53=a0_0x2c6390;if(_0x1d26f7)return JSON[_0x3efd53(0x13a)](_0x52d5e4);let _0x1a2960=L(_0x52d5e4['parent_task_id'],_0x3efd53(0xe1)),_0x2ae310=L(_0x52d5e4[_0x3efd53(0xec)],'<pending>'),_0x57f841=_0x52d5e4[_0x3efd53(0xf0)]?_0x3efd53(0x12f)+_0x52d5e4['error_code']+':'+(_0x52d5e4[_0x3efd53(0x103)]??''):'';return _0x3efd53(0x10f)+_0x52d5e4[_0x3efd53(0xf3)]+'\x20from='+L(_0x52d5e4['from_alias'],_0x3efd53(0xd9))+'\x20to='+L(_0x52d5e4[_0x3efd53(0x100)],_0x3efd53(0xd9))+_0x3efd53(0xd4)+_0x2ae310+_0x3efd53(0xed)+_0x1a2960+_0x3efd53(0xea)+L(_0x52d5e4[_0x3efd53(0xcd)],_0x3efd53(0xd9))+_0x3efd53(0xc8)+_0x52d5e4['transport']+_0x3efd53(0xcb)+_0x52d5e4[_0x3efd53(0xbc)]+'\x20lifecycle='+_0x52d5e4['lifecycle_tracking']+_0x57f841;}function U(_0x1ba4d3){const _0x1631de=a0_0x2c6390;return{'event':{'sending':_0x1631de(0x129),'delivered':_0x1631de(0x133),'failed':'task.send.failed','acked':_0x1631de(0xfd),'started':_0x1631de(0xc1),'replied':_0x1631de(0xf1),'expired':_0x1631de(0x135)}[_0x1ba4d3[_0x1631de(0xf3)]],..._0x1ba4d3};}function j(_0x3aab8f){const _0x29551d=a0_0x2c6390;let _0xec6f81=_0x3aab8f?.[_0x29551d(0xec)]||_0x3aab8f?.[_0x29551d(0x134)]||_0x3aab8f?.['id'];if(_0xec6f81)return String(_0xec6f81);let _0x38dcc2=_0x3aab8f?.[_0x29551d(0x108)]?.[0x0]?.[_0x29551d(0x113)];if(typeof _0x38dcc2!==_0x29551d(0xba))return null;try{let _0x4f2739=JSON[_0x29551d(0xdd)](_0x38dcc2);return _0x4f2739?.[_0x29551d(0xec)]||_0x4f2739?.[_0x29551d(0x134)]||_0x4f2739?.['id']||null;}catch{return null;}}function a0_0x3da2(){const _0x11378e=['agent','connected','body','abort','catch','[commhub:task]\x20','heartbeatTimer','ack_inbox','autoConnect','text','processInbox','640jXkdgP','getReader','SSE\x20error:\x20','report_status','task','CommHub\x20response\x20omitted\x20task_id','heartbeatInterval','getAllStatus','from_session','toTimeString','1107224ZqdUwb','networkId','500866ZzADmw','completed','transport','SSE\x20reconnecting\x20in\x20','parentTaskId','replace','Authorization','min','task.send.start','running','token','alias','5740931tqBXRv','heartbeat\x20failed:\x20','\x20error=','[REDACTED]','call','/mcp','task.send.delivered','message_id','task.expired','lifecycleTracking','unknown\x20error','CommHub\x20rejected\x20task','s...','stringify','string','delivered','duration_ms','12zRfWYI','error','sending','new_task','task.started','json','1148408tvJGYB','now','send_task','connect','type','\x20transport=','Bearer\x20','server','\x20duration_ms=','failed','network_id','sdk-','cwd','reconnectDelay','toAlias','idle','inbox\x20error:\x20','\x20task_id=','application/json,\x20text/event-stream','sseAbort','missing_task_id','decode','<unknown>','reply','SSE\x20connected','emit','parse','POST','slice','99FXQsFp','<missing>','log','data:\x20','8501622OLdxuU','new_message','messages','message','result','sleep','\x20network_id=','/events/','task_id','\x20parent_task_id=','fromAlias','23990ojwexk','error_code','task.replied','broadcast','status','connectSSE','disconnected','21777670frcXnW','url','application/json','name','startsWith','SSE\x20failed:\x20','signal','task.ack','split','toString','to_alias','disconnect','resumeId','error_message','match','send_reply','registered','tools/call','content','mcp_http'];a0_0x3da2=function(){return _0x11378e;};return a0_0x3da2();}async function X(_0x54fedf,_0x38349b){const _0x1e51aa=a0_0x2c6390;let _0x5d4125=_0x38349b[_0x1e51aa(0xc4)]??Date[_0x1e51aa(0xc4)],_0x15e997=_0x5d4125(),_0x29288d=(_0x3483d4,_0x26f624,_0x35f4f0,_0x590628)=>{const _0x5285eb=_0x1e51aa;_0x38349b[_0x5285eb(0xe2)](O(U({'from_alias':_0x54fedf['fromAlias'],'to_alias':_0x54fedf[_0x5285eb(0xd1)],'task_id':_0x26f624,'parent_task_id':_0x54fedf[_0x5285eb(0x125)],'network_id':_0x54fedf['networkId'],'transport':_0x54fedf[_0x5285eb(0x123)],'status':_0x3483d4,'duration_ms':_0x5d4125()-_0x15e997,'lifecycle_tracking':_0x54fedf[_0x5285eb(0x136)],..._0x35f4f0!==void 0x0?{'error_code':_0x590628||'send_failed','error_message':N(_0x35f4f0)}:{}})));};_0x29288d(_0x1e51aa(0xbf),null);try{let _0x73ce8d=await _0x38349b['send'](),_0x374e4e=j(_0x73ce8d);if(_0x374e4e)_0x29288d(_0x1e51aa(0xbb),_0x374e4e);else{if(_0x73ce8d?.['ok']===!0x1||_0x73ce8d?.[_0x1e51aa(0xbe)])_0x29288d(_0x1e51aa(0xcc),_0x374e4e,_0x73ce8d?.[_0x1e51aa(0xbe)]||_0x1e51aa(0x138),'send_rejected');else _0x29288d(_0x1e51aa(0xcc),null,_0x1e51aa(0x11a),_0x1e51aa(0xd7));}return _0x73ce8d;}catch(_0x4d84a5){throw _0x29288d(_0x1e51aa(0xcc),null,_0x4d84a5,'send_failed'),_0x4d84a5;}}async function Y(_0x45311a,_0xd17807){const _0x4a1675=a0_0x2c6390;return X({'fromAlias':_0x45311a[_0x4a1675(0xee)],'toAlias':_0x45311a['alias'],'parentTaskId':_0x45311a['parentTaskId']||null,'networkId':_0x45311a[_0x4a1675(0x120)]||null,'transport':_0x4a1675(0x109),'lifecycleTracking':'not_tracked'},_0xd17807);}class $ extends a0_0xae0a67{['url'];[a0_0x2c6390(0x12c)];[a0_0x2c6390(0x12b)];[a0_0x2c6390(0x10a)];[a0_0x2c6390(0x102)];[a0_0x2c6390(0x11b)];[a0_0x2c6390(0xd0)];[a0_0x2c6390(0x110)];[a0_0x2c6390(0xd6)];['running']=!0x1;constructor(_0x74e88f){const _0x26c287=a0_0x2c6390;super();if(this[_0x26c287(0xf7)]=_0x74e88f['url'][_0x26c287(0x126)](/\/$/,''),this['alias']=_0x74e88f[_0x26c287(0x12c)],this['token']=_0x74e88f[_0x26c287(0x12b)],this[_0x26c287(0x10a)]=_0x74e88f[_0x26c287(0x10a)]||'sdk',this[_0x26c287(0x102)]=_0x26c287(0xce)+_0x74e88f[_0x26c287(0x12c)]+'-'+Date['now']()[_0x26c287(0xff)](0x24),this[_0x26c287(0x11b)]=_0x74e88f['heartbeatInterval']??0x2bf20,this[_0x26c287(0xd0)]=_0x74e88f[_0x26c287(0xd0)]??0xbb8,_0x74e88f[_0x26c287(0x112)]!==!0x1)this[_0x26c287(0xc6)]();}['log'](_0x90ca08){const _0x51c70d=a0_0x2c6390;console['log']('['+new Date()[_0x51c70d(0x11e)]()[_0x51c70d(0xdf)](0x0,0x8)+']\x20[commhub:'+this[_0x51c70d(0x12c)]+']\x20'+_0x90ca08);}async[a0_0x2c6390(0x131)](_0x3bedae,_0x364aa0){const _0x109010=a0_0x2c6390;let _0xfc4924={'Content-Type':_0x109010(0xf8),'Accept':_0x109010(0xd5)};if(this[_0x109010(0x12b)])_0xfc4924[_0x109010(0x127)]=_0x109010(0xc9)+this[_0x109010(0x12b)];let _0x425e18=await(await fetch(this[_0x109010(0xf7)]+_0x109010(0x132),{'method':_0x109010(0xde),'headers':_0xfc4924,'body':JSON[_0x109010(0x13a)]({'jsonrpc':'2.0','id':Date[_0x109010(0xc4)](),'method':_0x109010(0x107),'params':{'name':_0x3bedae,'arguments':_0x364aa0}})}))[_0x109010(0x113)](),_0x1adc5c=_0x425e18[_0x109010(0x104)](/data: (.+)/),_0x3fd96e=_0x1adc5c?JSON[_0x109010(0xdd)](_0x1adc5c[0x1]):JSON[_0x109010(0xdd)](_0x425e18),_0x17bf6c=_0x3fd96e?.[_0x109010(0xe8)]?.[_0x109010(0x108)]?.[0x0]?.[_0x109010(0x113)];return _0x17bf6c?JSON[_0x109010(0xdd)](_0x17bf6c):_0x3fd96e;}async['connect'](){const _0x1c33a5=a0_0x2c6390;if(this['running'])return;this[_0x1c33a5(0x12a)]=!0x0,await this[_0x1c33a5(0xf3)]('idle'),this['log'](_0x1c33a5(0x106)),this[_0x1c33a5(0x110)]=setInterval(()=>{const _0x10cf80=_0x1c33a5;this[_0x10cf80(0xf3)](_0x10cf80(0xd2))[_0x10cf80(0x10e)](_0x207bfd=>this[_0x10cf80(0xe2)](_0x10cf80(0x12e)+_0x207bfd['message']));},this[_0x1c33a5(0x11b)]),this[_0x1c33a5(0xf4)]();}async[a0_0x2c6390(0x101)](){const _0x1280b7=a0_0x2c6390;if(this[_0x1280b7(0x12a)]=!0x1,this['sseAbort']?.[_0x1280b7(0x10d)](),this[_0x1280b7(0x110)])clearInterval(this['heartbeatTimer']);await this[_0x1280b7(0xf3)]('offline')[_0x1280b7(0x10e)](()=>{}),this[_0x1280b7(0xe2)]('disconnected');}async['send'](_0x412f4e,_0x478e09,_0x1b07a9='normal'){const _0x27f946=a0_0x2c6390;return Y({'alias':_0x412f4e,'fromAlias':this[_0x27f946(0x12c)]},{'log':_0x23d0f0=>console['log'](_0x23d0f0),'send':()=>this[_0x27f946(0x131)](_0x27f946(0xc5),{'alias':_0x412f4e,'task':_0x478e09,'priority':_0x1b07a9,'from_session':this[_0x27f946(0x12c)]})});}async[a0_0x2c6390(0xe7)](_0x16cceb,_0x1fabba){const _0x322d19=a0_0x2c6390;return this[_0x322d19(0x131)]('send_message',{'alias':_0x16cceb,'message':_0x1fabba,'from_session':this[_0x322d19(0x12c)]});}async[a0_0x2c6390(0xda)](_0x22102a,_0x4d7441,_0xdc4803=a0_0x2c6390(0x122)){const _0x236a22=a0_0x2c6390;return this[_0x236a22(0x131)](_0x236a22(0x105),{'in_reply_to':_0x22102a,'text':_0x4d7441,'status':_0xdc4803});}async['status'](_0x3251f7,_0x2b72b8){const _0x2f3937=a0_0x2c6390;return this['call'](_0x2f3937(0x118),{'resume_id':this[_0x2f3937(0x102)],'alias':this['alias'],'status':_0x3251f7,'server':a0_0x5b0365(),'hostname':a0_0x5b0365(),'agent':this[_0x2f3937(0x10a)],'project_dir':process[_0x2f3937(0xcf)](),..._0x2b72b8});}async[a0_0x2c6390(0x11c)](){return this['call']('get_all_status',{});}async[a0_0x2c6390(0xf2)](_0x58eab5,_0x569b95){const _0x52957d=a0_0x2c6390;return this[_0x52957d(0x131)](_0x52957d(0xf2),{'message':_0x58eab5,'filter_server':_0x569b95?.[_0x52957d(0xca)],'filter_status':_0x569b95?.['status']});}async[a0_0x2c6390(0xf4)](){const _0x2d4c31=a0_0x2c6390;let _0x5b9fbd=encodeURIComponent(this[_0x2d4c31(0x12c)]),_0x546add=this[_0x2d4c31(0xf7)]+_0x2d4c31(0xeb)+_0x5b9fbd,_0x5499d3=this[_0x2d4c31(0xd0)];while(this[_0x2d4c31(0x12a)]){try{this[_0x2d4c31(0xd6)]=new AbortController();let _0x4cd146={'Accept':'text/event-stream'};if(this['token'])_0x4cd146[_0x2d4c31(0x127)]=_0x2d4c31(0xc9)+this['token'];let _0x1b9cf8=await fetch(_0x546add,{'headers':_0x4cd146,'signal':this[_0x2d4c31(0xd6)][_0x2d4c31(0xfc)]});if(!_0x1b9cf8['ok']||!_0x1b9cf8['body']){this[_0x2d4c31(0xe2)](_0x2d4c31(0xfb)+_0x1b9cf8[_0x2d4c31(0xf3)]),await this[_0x2d4c31(0xe9)](_0x5499d3),_0x5499d3=Math[_0x2d4c31(0x128)](_0x5499d3*1.5,0xea60);continue;}_0x5499d3=this[_0x2d4c31(0xd0)];let _0x137eba=_0x1b9cf8[_0x2d4c31(0x10c)][_0x2d4c31(0x116)](),_0xd7c54c=new TextDecoder(),_0x27bbfd='';while(this[_0x2d4c31(0x12a)]){let {done:_0x3a8b6d,value:_0x4f8eb9}=await _0x137eba['read']();if(_0x3a8b6d)break;_0x27bbfd+=_0xd7c54c[_0x2d4c31(0xd8)](_0x4f8eb9,{'stream':!0x0});let _0x57ad78=_0x27bbfd[_0x2d4c31(0xfe)]('\x0a');_0x27bbfd=_0x57ad78['pop']()||'';for(let _0x17711e of _0x57ad78){if(!_0x17711e[_0x2d4c31(0xfa)](_0x2d4c31(0xe3)))continue;try{let _0xad1eca=JSON['parse'](_0x17711e[_0x2d4c31(0xdf)](0x6));if(_0xad1eca[_0x2d4c31(0xc7)]===_0x2d4c31(0x10b)){this[_0x2d4c31(0xe2)](_0x2d4c31(0xdb)),this[_0x2d4c31(0xdc)]('connected');continue;}if(_0xad1eca[_0x2d4c31(0xc7)]===_0x2d4c31(0xc0)||_0xad1eca[_0x2d4c31(0xc7)]===_0x2d4c31(0xe5)||_0xad1eca['type']==='broadcast')await this[_0x2d4c31(0x114)]();}catch{}}}}catch(_0x301a10){if(_0x301a10[_0x2d4c31(0xf9)]==='AbortError')break;this[_0x2d4c31(0xdc)](_0x2d4c31(0xbe),_0x301a10),this[_0x2d4c31(0xe2)](_0x2d4c31(0x117)+_0x301a10[_0x2d4c31(0xe7)]);}if(this['running'])this[_0x2d4c31(0xdc)](_0x2d4c31(0xf5)),this['log'](_0x2d4c31(0x124)+_0x5499d3/0x3e8+_0x2d4c31(0x139)),await this['sleep'](_0x5499d3),_0x5499d3=Math['min'](_0x5499d3*1.5,0xea60);}}async[a0_0x2c6390(0x114)](){const _0x169ea6=a0_0x2c6390;try{let _0x241706=(await this['call']('get_inbox',{'alias':this['alias'],'limit':0xa}))?.[_0x169ea6(0xe6)]||[];for(let _0xbaf486 of _0x241706)await this[_0x169ea6(0x131)](_0x169ea6(0x111),{'alias':this[_0x169ea6(0x12c)],'message_id':_0xbaf486['id']}),this[_0x169ea6(0xe2)]('←\x20'+_0xbaf486[_0x169ea6(0x11d)]+':\x20'+_0xbaf486[_0x169ea6(0x108)][_0x169ea6(0xdf)](0x0,0x3c)),this[_0x169ea6(0xdc)](_0x169ea6(0x119),_0xbaf486),this[_0x169ea6(0xdc)](_0x169ea6(0xe7),_0xbaf486);}catch(_0x16f8f4){this['log'](_0x169ea6(0xd3)+_0x16f8f4['message']);}}[a0_0x2c6390(0xe9)](_0x52f705){return new Promise(_0x59b510=>setTimeout(_0x59b510,_0x52f705));}}var F=$;export{F as default,$ as CommHub};
@@ -0,0 +1,14 @@
1
+ export declare const CLAUDE_CODE_RULES_RUNTIME = "claude";
2
+ export interface RulesDoorbellDeps {
3
+ callCommHub: (method: string, params: Record<string, unknown>) => Promise<any>;
4
+ workDir: string;
5
+ log: (msg: string) => void;
6
+ /** 技能的用户级根目录(~/.claude/skills)取自这里;缺省 os.homedir()。测试注入临时目录。 */
7
+ home?: string;
8
+ }
9
+ /** SSE 事件分派:是 rules_file 门铃就处理并返回 true;其它事件原样返回 false。 */
10
+ export declare function handleRulesFileEvent(event: {
11
+ type?: unknown;
12
+ } | null | undefined, deps: RulesDoorbellDeps): Promise<boolean>;
13
+ /** 连上 / 重连后补拉一次:断线期间桌面端可能已发起请求(hub 侧 60s 内仍 pending)。 */
14
+ export declare function drainRulesFileRequests(deps: RulesDoorbellDeps, why: string): Promise<number>;