@sleep2agi/agent-network 2.3.0-preview.202 → 2.3.0-preview.204

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.
@@ -0,0 +1,26 @@
1
+ export type BuildInfo = {
2
+ schema: 1;
3
+ commit: string;
4
+ dirty: boolean;
5
+ built_at: string;
6
+ source?: string;
7
+ };
8
+ export declare const BUILD_INFO_FILE = "build-info.json";
9
+ export declare function validateBuildInfo(raw: unknown): BuildInfo | null;
10
+ export type BuildInfoRead = {
11
+ kind: "present";
12
+ info: BuildInfo;
13
+ } | {
14
+ kind: "absent";
15
+ } | {
16
+ kind: "invalid";
17
+ error: string;
18
+ };
19
+ export declare function readBuildInfo(dir: string): BuildInfoRead;
20
+ /**
21
+ * 从**这个模块所在包**读 build-info。`bin/cli.ts` 与 `dist/bin/cli.js` 的层级不同,
22
+ * 所以向上找不超过 3 层,命中即返回;找不到返回 absent。
23
+ */
24
+ export declare function readPackageBuildInfo(): BuildInfoRead;
25
+ /** `anet --version` 里那一行的文本:三个状态各有各的说法,绝不把「没有」显示成「没问题」。 */
26
+ export declare function formatBuildLine(r: BuildInfoRead): string;
@@ -1 +1 @@
1
- const a0_0x507b29=a0_0x2317;(function(_0x16ec98,_0x96c12){const _0x46117a=a0_0x2317,_0x3a9eb=_0x16ec98();while(!![]){try{const _0x1970a7=-parseInt(_0x46117a(0x147))/0x1*(-parseInt(_0x46117a(0x172))/0x2)+parseInt(_0x46117a(0x11d))/0x3+-parseInt(_0x46117a(0x123))/0x4+parseInt(_0x46117a(0xfc))/0x5+-parseInt(_0x46117a(0x149))/0x6+-parseInt(_0x46117a(0x13a))/0x7*(-parseInt(_0x46117a(0x13f))/0x8)+-parseInt(_0x46117a(0x14e))/0x9*(-parseInt(_0x46117a(0x108))/0xa);if(_0x1970a7===_0x96c12)break;else _0x3a9eb['push'](_0x3a9eb['shift']());}catch(_0x34eae5){_0x3a9eb['push'](_0x3a9eb['shift']());}}}(a0_0x4bcf,0x6c85c));import{EventEmitter as a0_0x57b34e}from'events';import{hostname as a0_0x42303b}from'os';function a0_0x4bcf(){const _0x23a9b0=['now','startsWith','replace','from_session','send_reply','task','\x20transport=','content','119217VlrOQB','s...','status','error','ack_inbox','read','3126872gFmefF','sdk-','toString','log','string','message_id','error_code','getAllStatus','min','new_message','<unknown>','get_inbox','match','CommHub\x20rejected\x20task','task_id','toTimeString','alias','\x20network_id=','mcp_http','\x20parent_task_id=','2.0','connected','body','7nOXsOR','split','server','slice','\x20to=','6034064QpRIpg',']\x20[commhub:','signal','task.send.delivered','toAlias','send_rejected','normal','not_tracked','11ooehlB','token','4466136fLsLQK','emit','getReader','report_status','Authorization','18MzOXFT','cwd','send','error_message','message','type','offline','result','send_message','parentTaskId','registered','transport','[REDACTED]','url','idle','running','\x20task_id=','Bearer\x20','task.expired','resumeId','SSE\x20failed:\x20','heartbeatTimer','sseAbort','completed','fromAlias','send_task','\x20error=','tools/call','task.replied','connectSSE','from_alias','\x20from=','parse','json','data:\x20','agent','41858NeuiuF','SSE\x20connected','new_task','disconnect','abort','decode','processInbox','text','network_id','POST','to_alias','task.send.failed','\x20lifecycle=','heartbeatInterval','3234550pBbyRI','AbortError','<pending>','lifecycle_tracking','inbox\x20error:\x20','messages','disconnected','sdk','failed','call','SSE\x20error:\x20','broadcast','1497280OAFmRN','application/json,\x20text/event-stream','lifecycleTracking','connect','send_failed','name','task.started','missing_task_id','sending','networkId','/mcp','reconnectDelay','sleep'];a0_0x4bcf=function(){return _0x23a9b0;};return a0_0x4bcf();}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x46066e,_0x1838ff)=>(_0x46066e??_0x1838ff)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x501290){const _0x5a19c5=a0_0x2317;return(_0x501290 instanceof Error?_0x501290[_0x5a19c5(0x152)]:String(_0x501290??'unknown\x20error'))[_0x5a19c5(0x117)](K,_0x5a19c5(0x15a))['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x5a19c5(0x13d)](0x0,0xf0);}function O(_0x19c5e7,_0x461ba4=process.env.ANET_TASK_TRACE_FORMAT===a0_0x507b29(0x16f)){const _0x4d2d6b=a0_0x507b29;if(_0x461ba4)return JSON['stringify'](_0x19c5e7);let _0xa5445f=L(_0x19c5e7['parent_task_id'],'<missing>'),_0x4d5ac4=L(_0x19c5e7[_0x4d2d6b(0x131)],_0x4d2d6b(0xfe)),_0x29a84d=_0x19c5e7['error_code']?_0x4d2d6b(0x168)+_0x19c5e7[_0x4d2d6b(0x129)]+':'+(_0x19c5e7[_0x4d2d6b(0x151)]??''):'';return'[commhub:task]\x20'+_0x19c5e7['status']+_0x4d2d6b(0x16d)+L(_0x19c5e7[_0x4d2d6b(0x16c)],_0x4d2d6b(0x12d))+_0x4d2d6b(0x13e)+L(_0x19c5e7[_0x4d2d6b(0xf8)],_0x4d2d6b(0x12d))+_0x4d2d6b(0x15e)+_0x4d5ac4+_0x4d2d6b(0x136)+_0xa5445f+_0x4d2d6b(0x134)+L(_0x19c5e7[_0x4d2d6b(0xf6)],_0x4d2d6b(0x12d))+_0x4d2d6b(0x11b)+_0x19c5e7[_0x4d2d6b(0x159)]+'\x20duration_ms='+_0x19c5e7['duration_ms']+_0x4d2d6b(0xfa)+_0x19c5e7[_0x4d2d6b(0xff)]+_0x29a84d;}function U(_0x520dcd){const _0x35f0fe=a0_0x507b29;return{'event':{'sending':'task.send.start','delivered':_0x35f0fe(0x142),'failed':_0x35f0fe(0xf9),'acked':'task.ack','started':_0x35f0fe(0x10e),'replied':_0x35f0fe(0x16a),'expired':_0x35f0fe(0x160)}[_0x520dcd[_0x35f0fe(0x11f)]],..._0x520dcd};}function j(_0x255f2c){const _0x24e0fb=a0_0x507b29;let _0x1b1ae1=_0x255f2c?.[_0x24e0fb(0x131)]||_0x255f2c?.['message_id']||_0x255f2c?.['id'];if(_0x1b1ae1)return String(_0x1b1ae1);let _0xcd83d6=_0x255f2c?.['content']?.[0x0]?.[_0x24e0fb(0xf5)];if(typeof _0xcd83d6!==_0x24e0fb(0x127))return null;try{let _0x5e8d38=JSON[_0x24e0fb(0x16e)](_0xcd83d6);return _0x5e8d38?.[_0x24e0fb(0x131)]||_0x5e8d38?.[_0x24e0fb(0x128)]||_0x5e8d38?.['id']||null;}catch{return null;}}function a0_0x2317(_0x18d3f0,_0x3317b5){_0x18d3f0=_0x18d3f0-0xf5;const _0x4bcfa1=a0_0x4bcf();let _0x2317ef=_0x4bcfa1[_0x18d3f0];return _0x2317ef;}async function X(_0x5919ea,_0x5032c7){const _0x57767f=a0_0x507b29;let _0x2a2351=_0x5032c7[_0x57767f(0x115)]??Date['now'],_0x185e3a=_0x2a2351(),_0xb1c420=(_0x523f26,_0x5d5333,_0xa19a70,_0x54a403)=>{const _0x3b07b6=_0x57767f;_0x5032c7[_0x3b07b6(0x126)](O(U({'from_alias':_0x5919ea[_0x3b07b6(0x166)],'to_alias':_0x5919ea[_0x3b07b6(0x143)],'task_id':_0x5d5333,'parent_task_id':_0x5919ea[_0x3b07b6(0x157)],'network_id':_0x5919ea[_0x3b07b6(0x111)],'transport':_0x5919ea['transport'],'status':_0x523f26,'duration_ms':_0x2a2351()-_0x185e3a,'lifecycle_tracking':_0x5919ea[_0x3b07b6(0x10a)],..._0xa19a70!==void 0x0?{'error_code':_0x54a403||_0x3b07b6(0x10c),'error_message':N(_0xa19a70)}:{}})));};_0xb1c420(_0x57767f(0x110),null);try{let _0x17074a=await _0x5032c7[_0x57767f(0x150)](),_0x5e6e62=j(_0x17074a);if(_0x5e6e62)_0xb1c420('delivered',_0x5e6e62);else{if(_0x17074a?.['ok']===!0x1||_0x17074a?.['error'])_0xb1c420(_0x57767f(0x104),_0x5e6e62,_0x17074a?.[_0x57767f(0x120)]||_0x57767f(0x130),_0x57767f(0x144));else _0xb1c420(_0x57767f(0x104),null,'CommHub\x20response\x20omitted\x20task_id',_0x57767f(0x10f));}return _0x17074a;}catch(_0x540b07){throw _0xb1c420('failed',null,_0x540b07,_0x57767f(0x10c)),_0x540b07;}}async function Y(_0x27590e,_0x135bf7){const _0x482b75=a0_0x507b29;return X({'fromAlias':_0x27590e[_0x482b75(0x166)],'toAlias':_0x27590e[_0x482b75(0x133)],'parentTaskId':_0x27590e[_0x482b75(0x157)]||null,'networkId':_0x27590e[_0x482b75(0x111)]||null,'transport':_0x482b75(0x135),'lifecycleTracking':_0x482b75(0x146)},_0x135bf7);}class $ extends a0_0x57b34e{[a0_0x507b29(0x15b)];['alias'];[a0_0x507b29(0x148)];[a0_0x507b29(0x171)];[a0_0x507b29(0x161)];['heartbeatInterval'];['reconnectDelay'];[a0_0x507b29(0x163)];[a0_0x507b29(0x164)];[a0_0x507b29(0x15d)]=!0x1;constructor(_0x183ce4){const _0x3abecf=a0_0x507b29;super();if(this[_0x3abecf(0x15b)]=_0x183ce4['url'][_0x3abecf(0x117)](/\/$/,''),this[_0x3abecf(0x133)]=_0x183ce4[_0x3abecf(0x133)],this['token']=_0x183ce4[_0x3abecf(0x148)],this[_0x3abecf(0x171)]=_0x183ce4[_0x3abecf(0x171)]||_0x3abecf(0x103),this[_0x3abecf(0x161)]=_0x3abecf(0x124)+_0x183ce4['alias']+'-'+Date['now']()[_0x3abecf(0x125)](0x24),this[_0x3abecf(0xfb)]=_0x183ce4[_0x3abecf(0xfb)]??0x2bf20,this[_0x3abecf(0x113)]=_0x183ce4[_0x3abecf(0x113)]??0xbb8,_0x183ce4['autoConnect']!==!0x1)this[_0x3abecf(0x10b)]();}['log'](_0x120f21){const _0x5c1516=a0_0x507b29;console['log']('['+new Date()[_0x5c1516(0x132)]()[_0x5c1516(0x13d)](0x0,0x8)+_0x5c1516(0x140)+this[_0x5c1516(0x133)]+']\x20'+_0x120f21);}async[a0_0x507b29(0x105)](_0x49c685,_0x2e71f1){const _0x481161=a0_0x507b29;let _0x141d0f={'Content-Type':'application/json','Accept':_0x481161(0x109)};if(this[_0x481161(0x148)])_0x141d0f[_0x481161(0x14d)]='Bearer\x20'+this[_0x481161(0x148)];let _0x4cd6f9=await(await fetch(this['url']+_0x481161(0x112),{'method':_0x481161(0xf7),'headers':_0x141d0f,'body':JSON['stringify']({'jsonrpc':_0x481161(0x137),'id':Date[_0x481161(0x115)](),'method':_0x481161(0x169),'params':{'name':_0x49c685,'arguments':_0x2e71f1}})}))['text'](),_0x38247e=_0x4cd6f9[_0x481161(0x12f)](/data: (.+)/),_0x1ccd44=_0x38247e?JSON[_0x481161(0x16e)](_0x38247e[0x1]):JSON[_0x481161(0x16e)](_0x4cd6f9),_0x3ed400=_0x1ccd44?.[_0x481161(0x155)]?.[_0x481161(0x11c)]?.[0x0]?.[_0x481161(0xf5)];return _0x3ed400?JSON[_0x481161(0x16e)](_0x3ed400):_0x1ccd44;}async['connect'](){const _0x55ce69=a0_0x507b29;if(this['running'])return;this['running']=!0x0,await this['status'](_0x55ce69(0x15c)),this['log'](_0x55ce69(0x158)),this[_0x55ce69(0x163)]=setInterval(()=>{const _0x68f51d=_0x55ce69;this[_0x68f51d(0x11f)](_0x68f51d(0x15c))['catch'](_0xd473c1=>this['log']('heartbeat\x20failed:\x20'+_0xd473c1[_0x68f51d(0x152)]));},this['heartbeatInterval']),this['connectSSE']();}async[a0_0x507b29(0x175)](){const _0x134691=a0_0x507b29;if(this[_0x134691(0x15d)]=!0x1,this[_0x134691(0x164)]?.[_0x134691(0x176)](),this[_0x134691(0x163)])clearInterval(this[_0x134691(0x163)]);await this['status'](_0x134691(0x154))['catch'](()=>{}),this[_0x134691(0x126)](_0x134691(0x102));}async['send'](_0x3a038f,_0x329c28,_0x20576e=a0_0x507b29(0x145)){const _0x3d216a=a0_0x507b29;return Y({'alias':_0x3a038f,'fromAlias':this['alias']},{'log':_0x3b5e3f=>console[_0x3d216a(0x126)](_0x3b5e3f),'send':()=>this['call'](_0x3d216a(0x167),{'alias':_0x3a038f,'task':_0x329c28,'priority':_0x20576e,'from_session':this[_0x3d216a(0x133)]})});}async['message'](_0x428e42,_0x1181bd){const _0x580b04=a0_0x507b29;return this['call'](_0x580b04(0x156),{'alias':_0x428e42,'message':_0x1181bd,'from_session':this[_0x580b04(0x133)]});}async['reply'](_0x5a8abe,_0xa1cd2e,_0x5e8064=a0_0x507b29(0x165)){const _0x100e2b=a0_0x507b29;return this['call'](_0x100e2b(0x119),{'in_reply_to':_0x5a8abe,'text':_0xa1cd2e,'status':_0x5e8064});}async[a0_0x507b29(0x11f)](_0x15aa81,_0x280c09){const _0x1752d7=a0_0x507b29;return this[_0x1752d7(0x105)](_0x1752d7(0x14c),{'resume_id':this['resumeId'],'alias':this[_0x1752d7(0x133)],'status':_0x15aa81,'server':a0_0x42303b(),'hostname':a0_0x42303b(),'agent':this[_0x1752d7(0x171)],'project_dir':process[_0x1752d7(0x14f)](),..._0x280c09});}async[a0_0x507b29(0x12a)](){return this['call']('get_all_status',{});}async['broadcast'](_0x5c612e,_0x444e8e){const _0xc1f412=a0_0x507b29;return this[_0xc1f412(0x105)](_0xc1f412(0x107),{'message':_0x5c612e,'filter_server':_0x444e8e?.[_0xc1f412(0x13c)],'filter_status':_0x444e8e?.[_0xc1f412(0x11f)]});}async[a0_0x507b29(0x16b)](){const _0x5a9fbc=a0_0x507b29;let _0x5addbf=encodeURIComponent(this['alias']),_0x18b892=this[_0x5a9fbc(0x15b)]+'/events/'+_0x5addbf,_0x2cf1ae=this['reconnectDelay'];while(this['running']){try{this[_0x5a9fbc(0x164)]=new AbortController();let _0x25bfb7={'Accept':'text/event-stream'};if(this[_0x5a9fbc(0x148)])_0x25bfb7[_0x5a9fbc(0x14d)]=_0x5a9fbc(0x15f)+this[_0x5a9fbc(0x148)];let _0x22ac6c=await fetch(_0x18b892,{'headers':_0x25bfb7,'signal':this[_0x5a9fbc(0x164)][_0x5a9fbc(0x141)]});if(!_0x22ac6c['ok']||!_0x22ac6c['body']){this[_0x5a9fbc(0x126)](_0x5a9fbc(0x162)+_0x22ac6c[_0x5a9fbc(0x11f)]),await this['sleep'](_0x2cf1ae),_0x2cf1ae=Math['min'](_0x2cf1ae*1.5,0xea60);continue;}_0x2cf1ae=this[_0x5a9fbc(0x113)];let _0x57bd6a=_0x22ac6c[_0x5a9fbc(0x139)][_0x5a9fbc(0x14b)](),_0x2db7a8=new TextDecoder(),_0x3ca753='';while(this[_0x5a9fbc(0x15d)]){let {done:_0x57571a,value:_0x19592e}=await _0x57bd6a[_0x5a9fbc(0x122)]();if(_0x57571a)break;_0x3ca753+=_0x2db7a8[_0x5a9fbc(0x177)](_0x19592e,{'stream':!0x0});let _0x1dbbe9=_0x3ca753[_0x5a9fbc(0x13b)]('\x0a');_0x3ca753=_0x1dbbe9['pop']()||'';for(let _0x4bba92 of _0x1dbbe9){if(!_0x4bba92[_0x5a9fbc(0x116)](_0x5a9fbc(0x170)))continue;try{let _0x438ad0=JSON[_0x5a9fbc(0x16e)](_0x4bba92[_0x5a9fbc(0x13d)](0x6));if(_0x438ad0['type']===_0x5a9fbc(0x138)){this['log'](_0x5a9fbc(0x173)),this['emit']('connected');continue;}if(_0x438ad0[_0x5a9fbc(0x153)]===_0x5a9fbc(0x174)||_0x438ad0[_0x5a9fbc(0x153)]===_0x5a9fbc(0x12c)||_0x438ad0[_0x5a9fbc(0x153)]===_0x5a9fbc(0x107))await this[_0x5a9fbc(0x178)]();}catch{}}}}catch(_0x42844f){if(_0x42844f[_0x5a9fbc(0x10d)]===_0x5a9fbc(0xfd))break;this['emit'](_0x5a9fbc(0x120),_0x42844f),this[_0x5a9fbc(0x126)](_0x5a9fbc(0x106)+_0x42844f[_0x5a9fbc(0x152)]);}if(this[_0x5a9fbc(0x15d)])this['emit']('disconnected'),this[_0x5a9fbc(0x126)]('SSE\x20reconnecting\x20in\x20'+_0x2cf1ae/0x3e8+_0x5a9fbc(0x11e)),await this[_0x5a9fbc(0x114)](_0x2cf1ae),_0x2cf1ae=Math[_0x5a9fbc(0x12b)](_0x2cf1ae*1.5,0xea60);}}async['processInbox'](){const _0x766d53=a0_0x507b29;try{let _0x128712=(await this['call'](_0x766d53(0x12e),{'alias':this['alias'],'limit':0xa}))?.[_0x766d53(0x101)]||[];for(let _0xf30d25 of _0x128712)await this[_0x766d53(0x105)](_0x766d53(0x121),{'alias':this[_0x766d53(0x133)],'message_id':_0xf30d25['id']}),this[_0x766d53(0x126)]('←\x20'+_0xf30d25[_0x766d53(0x118)]+':\x20'+_0xf30d25[_0x766d53(0x11c)][_0x766d53(0x13d)](0x0,0x3c)),this[_0x766d53(0x14a)](_0x766d53(0x11a),_0xf30d25),this['emit'](_0x766d53(0x152),_0xf30d25);}catch(_0x281ee7){this[_0x766d53(0x126)](_0x766d53(0x100)+_0x281ee7[_0x766d53(0x152)]);}}['sleep'](_0x18b940){return new Promise(_0x35d2fd=>setTimeout(_0x35d2fd,_0x18b940));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x5f3d88=a0_0x3353;(function(_0x2464c1,_0x59284a){const _0x5d274d=a0_0x3353,_0x51799b=_0x2464c1();while(!![]){try{const _0x573659=-parseInt(_0x5d274d(0x145))/0x1*(parseInt(_0x5d274d(0x13f))/0x2)+-parseInt(_0x5d274d(0x162))/0x3*(-parseInt(_0x5d274d(0x141))/0x4)+-parseInt(_0x5d274d(0x109))/0x5*(-parseInt(_0x5d274d(0x156))/0x6)+parseInt(_0x5d274d(0xfc))/0x7*(parseInt(_0x5d274d(0x14e))/0x8)+-parseInt(_0x5d274d(0x100))/0x9+parseInt(_0x5d274d(0x13d))/0xa+parseInt(_0x5d274d(0xfd))/0xb*(-parseInt(_0x5d274d(0x11a))/0xc);if(_0x573659===_0x59284a)break;else _0x51799b['push'](_0x51799b['shift']());}catch(_0x4e5f88){_0x51799b['push'](_0x51799b['shift']());}}}(a0_0x1b98,0x29477));import{EventEmitter as a0_0x592341}from'events';function a0_0x3353(_0x57f7d5,_0x5ea9ff){_0x57f7d5=_0x57f7d5-0xe2;const _0x1b98ad=a0_0x1b98();let _0x3353ea=_0x1b98ad[_0x57f7d5];return _0x3353ea;}import{hostname as a0_0x2e6272}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4f7ee7,_0x19913c)=>(_0x4f7ee7??_0x19913c)[a0_0x5f3d88(0x154)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x5de5a1){const _0x52e08d=a0_0x5f3d88;return(_0x5de5a1 instanceof Error?_0x5de5a1[_0x52e08d(0x121)]:String(_0x5de5a1??_0x52e08d(0x11e)))[_0x52e08d(0x154)](K,'[REDACTED]')[_0x52e08d(0x154)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x52e08d(0x115)](0x0,0xf0);}function O(_0x59f58c,_0x2b8242=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5f3d88(0x161)){const _0x40e048=a0_0x5f3d88;if(_0x2b8242)return JSON[_0x40e048(0x15d)](_0x59f58c);let _0x18dba5=L(_0x59f58c[_0x40e048(0x117)],_0x40e048(0x102)),_0x42813d=L(_0x59f58c['task_id'],'<pending>'),_0x31e702=_0x59f58c[_0x40e048(0xea)]?_0x40e048(0x14a)+_0x59f58c[_0x40e048(0xea)]+':'+(_0x59f58c[_0x40e048(0x113)]??''):'';return _0x40e048(0x118)+_0x59f58c[_0x40e048(0x15e)]+_0x40e048(0xe7)+L(_0x59f58c[_0x40e048(0xe9)],_0x40e048(0x14c))+_0x40e048(0x147)+L(_0x59f58c['to_alias'],'<unknown>')+_0x40e048(0x12c)+_0x42813d+_0x40e048(0xfa)+_0x18dba5+_0x40e048(0x163)+L(_0x59f58c[_0x40e048(0x134)],'<unknown>')+_0x40e048(0x128)+_0x59f58c['transport']+_0x40e048(0x120)+_0x59f58c['duration_ms']+'\x20lifecycle='+_0x59f58c['lifecycle_tracking']+_0x31e702;}function U(_0x5a6462){const _0x1d55bd=a0_0x5f3d88;return{'event':{'sending':_0x1d55bd(0x122),'delivered':_0x1d55bd(0xf9),'failed':_0x1d55bd(0x14b),'acked':_0x1d55bd(0x139),'started':'task.started','replied':_0x1d55bd(0x136),'expired':'task.expired'}[_0x5a6462['status']],..._0x5a6462};}function a0_0x1b98(){const _0x459959=['task.replied','disconnect','CommHub\x20rejected\x20task','task.ack','Bearer\x20','normal','sdk','2618570hRmhjT','report_status','7318foiRAX','pop','612828QhqVrY','agent','new_task','send_reply','27aptTmD','POST','\x20to=','disconnected','sseAbort','\x20error=','task.send.failed','<unknown>','get_all_status','1168sNHrBa','alias','connect','SSE\x20reconnecting\x20in\x20','getReader','reconnectDelay','replace','SSE\x20failed:\x20','24rkYZDB','call','running','text','match','type','parse','stringify','status','min','connectSSE','json','3KBcVsd','\x20network_id=','AbortError','error','token','missing_task_id','body','from_session','registered','completed','mcp_http','application/json,\x20text/event-stream','\x20from=','sending','from_alias','error_code','broadcast','parentTaskId','autoConnect','send_message','get_inbox','data:\x20','read','heartbeatInterval','messages','inbox\x20error:\x20','task_id','content','toString','not_tracked','task.send.delivered','\x20parent_task_id=','transport','7483XWcSZG','1624381LlOfUN','reply','connected','1797111UuWLMd','emit','<missing>','SSE\x20error:\x20','now','networkId','send_task','ack_inbox','message_id','55105dJXcqI','send','cwd','sleep','send_failed','delivered','log','resumeId','processInbox','result','error_message','getAllStatus','slice','toTimeString','parent_task_id','[commhub:task]\x20','fromAlias','12GjbfOp','catch','SSE\x20connected','CommHub\x20response\x20omitted\x20task_id','unknown\x20error','text/event-stream','\x20duration_ms=','message','task.send.start','heartbeatTimer','failed','toAlias','Authorization','lifecycleTracking','\x20transport=','url','/events/','heartbeat\x20failed:\x20','\x20task_id=','tools/call','abort','split','name','new_message','idle','signal','network_id','string'];a0_0x1b98=function(){return _0x459959;};return a0_0x1b98();}function j(_0xe529b7){const _0x7a9611=a0_0x5f3d88;let _0x5aca10=_0xe529b7?.[_0x7a9611(0xf5)]||_0xe529b7?.[_0x7a9611(0x108)]||_0xe529b7?.['id'];if(_0x5aca10)return String(_0x5aca10);let _0x1c6258=_0xe529b7?.[_0x7a9611(0xf6)]?.[0x0]?.[_0x7a9611(0x159)];if(typeof _0x1c6258!==_0x7a9611(0x135))return null;try{let _0x243337=JSON[_0x7a9611(0x15c)](_0x1c6258);return _0x243337?.['task_id']||_0x243337?.[_0x7a9611(0x108)]||_0x243337?.['id']||null;}catch{return null;}}async function X(_0x417aa8,_0x185c0a){const _0x22b96e=a0_0x5f3d88;let _0x3ee057=_0x185c0a[_0x22b96e(0x104)]??Date[_0x22b96e(0x104)],_0xe09c1e=_0x3ee057(),_0x1025a6=(_0x2dd2ca,_0x44727f,_0x3df653,_0xb13792)=>{const _0x15e438=_0x22b96e;_0x185c0a['log'](O(U({'from_alias':_0x417aa8['fromAlias'],'to_alias':_0x417aa8[_0x15e438(0x125)],'task_id':_0x44727f,'parent_task_id':_0x417aa8[_0x15e438(0xec)],'network_id':_0x417aa8['networkId'],'transport':_0x417aa8[_0x15e438(0xfb)],'status':_0x2dd2ca,'duration_ms':_0x3ee057()-_0xe09c1e,'lifecycle_tracking':_0x417aa8[_0x15e438(0x127)],..._0x3df653!==void 0x0?{'error_code':_0xb13792||_0x15e438(0x10d),'error_message':N(_0x3df653)}:{}})));};_0x1025a6(_0x22b96e(0xe8),null);try{let _0x5ea8ff=await _0x185c0a[_0x22b96e(0x10a)](),_0x1be2f5=j(_0x5ea8ff);if(_0x1be2f5)_0x1025a6(_0x22b96e(0x10e),_0x1be2f5);else{if(_0x5ea8ff?.['ok']===!0x1||_0x5ea8ff?.[_0x22b96e(0x165)])_0x1025a6('failed',_0x1be2f5,_0x5ea8ff?.[_0x22b96e(0x165)]||_0x22b96e(0x138),'send_rejected');else _0x1025a6(_0x22b96e(0x124),null,_0x22b96e(0x11d),_0x22b96e(0x167));}return _0x5ea8ff;}catch(_0x510b7b){throw _0x1025a6('failed',null,_0x510b7b,_0x22b96e(0x10d)),_0x510b7b;}}async function Y(_0x1b505a,_0x3c1dcb){const _0x294a30=a0_0x5f3d88;return X({'fromAlias':_0x1b505a[_0x294a30(0x119)],'toAlias':_0x1b505a[_0x294a30(0x14f)],'parentTaskId':_0x1b505a[_0x294a30(0xec)]||null,'networkId':_0x1b505a[_0x294a30(0x105)]||null,'transport':_0x294a30(0xe5),'lifecycleTracking':_0x294a30(0xf8)},_0x3c1dcb);}class $ extends a0_0x592341{[a0_0x5f3d88(0x129)];[a0_0x5f3d88(0x14f)];['token'];[a0_0x5f3d88(0x142)];[a0_0x5f3d88(0x110)];[a0_0x5f3d88(0xf2)];['reconnectDelay'];[a0_0x5f3d88(0x123)];[a0_0x5f3d88(0x149)];['running']=!0x1;constructor(_0xd79857){const _0x539994=a0_0x5f3d88;super();if(this[_0x539994(0x129)]=_0xd79857[_0x539994(0x129)][_0x539994(0x154)](/\/$/,''),this['alias']=_0xd79857[_0x539994(0x14f)],this[_0x539994(0x166)]=_0xd79857[_0x539994(0x166)],this[_0x539994(0x142)]=_0xd79857[_0x539994(0x142)]||_0x539994(0x13c),this[_0x539994(0x110)]='sdk-'+_0xd79857['alias']+'-'+Date[_0x539994(0x104)]()[_0x539994(0xf7)](0x24),this[_0x539994(0xf2)]=_0xd79857['heartbeatInterval']??0x2bf20,this[_0x539994(0x153)]=_0xd79857[_0x539994(0x153)]??0xbb8,_0xd79857[_0x539994(0xed)]!==!0x1)this['connect']();}[a0_0x5f3d88(0x10f)](_0x19760c){const _0x577cfe=a0_0x5f3d88;console[_0x577cfe(0x10f)]('['+new Date()[_0x577cfe(0x116)]()[_0x577cfe(0x115)](0x0,0x8)+']\x20[commhub:'+this[_0x577cfe(0x14f)]+']\x20'+_0x19760c);}async[a0_0x5f3d88(0x157)](_0x213755,_0x31501c){const _0x1d9c19=a0_0x5f3d88;let _0x4414c4={'Content-Type':'application/json','Accept':_0x1d9c19(0xe6)};if(this[_0x1d9c19(0x166)])_0x4414c4['Authorization']=_0x1d9c19(0x13a)+this[_0x1d9c19(0x166)];let _0x110e76=await(await fetch(this[_0x1d9c19(0x129)]+'/mcp',{'method':_0x1d9c19(0x146),'headers':_0x4414c4,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date[_0x1d9c19(0x104)](),'method':_0x1d9c19(0x12d),'params':{'name':_0x213755,'arguments':_0x31501c}})}))[_0x1d9c19(0x159)](),_0x53f247=_0x110e76[_0x1d9c19(0x15a)](/data: (.+)/),_0x1f5a25=_0x53f247?JSON['parse'](_0x53f247[0x1]):JSON[_0x1d9c19(0x15c)](_0x110e76),_0x404f29=_0x1f5a25?.[_0x1d9c19(0x112)]?.[_0x1d9c19(0xf6)]?.[0x0]?.[_0x1d9c19(0x159)];return _0x404f29?JSON[_0x1d9c19(0x15c)](_0x404f29):_0x1f5a25;}async[a0_0x5f3d88(0x150)](){const _0x531463=a0_0x5f3d88;if(this[_0x531463(0x158)])return;this['running']=!0x0,await this[_0x531463(0x15e)](_0x531463(0x132)),this[_0x531463(0x10f)](_0x531463(0xe3)),this[_0x531463(0x123)]=setInterval(()=>{const _0x55457a=_0x531463;this[_0x55457a(0x15e)]('idle')['catch'](_0x1f0172=>this[_0x55457a(0x10f)](_0x55457a(0x12b)+_0x1f0172[_0x55457a(0x121)]));},this[_0x531463(0xf2)]),this[_0x531463(0x160)]();}async[a0_0x5f3d88(0x137)](){const _0x5c2e33=a0_0x5f3d88;if(this['running']=!0x1,this[_0x5c2e33(0x149)]?.[_0x5c2e33(0x12e)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this[_0x5c2e33(0x15e)]('offline')[_0x5c2e33(0x11b)](()=>{}),this[_0x5c2e33(0x10f)](_0x5c2e33(0x148));}async[a0_0x5f3d88(0x10a)](_0x25dafd,_0x2beabf,_0x1e9293=a0_0x5f3d88(0x13b)){const _0x35a737=a0_0x5f3d88;return Y({'alias':_0x25dafd,'fromAlias':this[_0x35a737(0x14f)]},{'log':_0x5b1672=>console[_0x35a737(0x10f)](_0x5b1672),'send':()=>this[_0x35a737(0x157)](_0x35a737(0x106),{'alias':_0x25dafd,'task':_0x2beabf,'priority':_0x1e9293,'from_session':this[_0x35a737(0x14f)]})});}async[a0_0x5f3d88(0x121)](_0x3fed29,_0x3b7746){const _0x4bbbca=a0_0x5f3d88;return this[_0x4bbbca(0x157)](_0x4bbbca(0xee),{'alias':_0x3fed29,'message':_0x3b7746,'from_session':this[_0x4bbbca(0x14f)]});}async[a0_0x5f3d88(0xfe)](_0x3fe9a3,_0x55b713,_0x48e718=a0_0x5f3d88(0xe4)){const _0x2ba835=a0_0x5f3d88;return this[_0x2ba835(0x157)](_0x2ba835(0x144),{'in_reply_to':_0x3fe9a3,'text':_0x55b713,'status':_0x48e718});}async[a0_0x5f3d88(0x15e)](_0x4e93a8,_0x1f62f6){const _0x5f08a9=a0_0x5f3d88;return this[_0x5f08a9(0x157)](_0x5f08a9(0x13e),{'resume_id':this[_0x5f08a9(0x110)],'alias':this[_0x5f08a9(0x14f)],'status':_0x4e93a8,'server':a0_0x2e6272(),'hostname':a0_0x2e6272(),'agent':this[_0x5f08a9(0x142)],'project_dir':process[_0x5f08a9(0x10b)](),..._0x1f62f6});}async[a0_0x5f3d88(0x114)](){const _0x26e53a=a0_0x5f3d88;return this[_0x26e53a(0x157)](_0x26e53a(0x14d),{});}async[a0_0x5f3d88(0xeb)](_0x39d57f,_0x456571){const _0x1be367=a0_0x5f3d88;return this[_0x1be367(0x157)](_0x1be367(0xeb),{'message':_0x39d57f,'filter_server':_0x456571?.['server'],'filter_status':_0x456571?.[_0x1be367(0x15e)]});}async[a0_0x5f3d88(0x160)](){const _0x2350e0=a0_0x5f3d88;let _0x50ff44=encodeURIComponent(this[_0x2350e0(0x14f)]),_0x455403=this[_0x2350e0(0x129)]+_0x2350e0(0x12a)+_0x50ff44,_0x376dd6=this['reconnectDelay'];while(this[_0x2350e0(0x158)]){try{this[_0x2350e0(0x149)]=new AbortController();let _0x59be7a={'Accept':_0x2350e0(0x11f)};if(this[_0x2350e0(0x166)])_0x59be7a[_0x2350e0(0x126)]=_0x2350e0(0x13a)+this[_0x2350e0(0x166)];let _0x16f9fd=await fetch(_0x455403,{'headers':_0x59be7a,'signal':this['sseAbort'][_0x2350e0(0x133)]});if(!_0x16f9fd['ok']||!_0x16f9fd[_0x2350e0(0x168)]){this[_0x2350e0(0x10f)](_0x2350e0(0x155)+_0x16f9fd[_0x2350e0(0x15e)]),await this[_0x2350e0(0x10c)](_0x376dd6),_0x376dd6=Math[_0x2350e0(0x15f)](_0x376dd6*1.5,0xea60);continue;}_0x376dd6=this[_0x2350e0(0x153)];let _0x19918e=_0x16f9fd[_0x2350e0(0x168)][_0x2350e0(0x152)](),_0xf67c34=new TextDecoder(),_0x220f8a='';while(this['running']){let {done:_0x2c76ff,value:_0x426481}=await _0x19918e[_0x2350e0(0xf1)]();if(_0x2c76ff)break;_0x220f8a+=_0xf67c34['decode'](_0x426481,{'stream':!0x0});let _0x13e528=_0x220f8a[_0x2350e0(0x12f)]('\x0a');_0x220f8a=_0x13e528[_0x2350e0(0x140)]()||'';for(let _0x5aea75 of _0x13e528){if(!_0x5aea75['startsWith'](_0x2350e0(0xf0)))continue;try{let _0xf7fd19=JSON[_0x2350e0(0x15c)](_0x5aea75[_0x2350e0(0x115)](0x6));if(_0xf7fd19[_0x2350e0(0x15b)]===_0x2350e0(0xff)){this[_0x2350e0(0x10f)](_0x2350e0(0x11c)),this['emit'](_0x2350e0(0xff));continue;}if(_0xf7fd19['type']===_0x2350e0(0x143)||_0xf7fd19['type']===_0x2350e0(0x131)||_0xf7fd19['type']==='broadcast')await this['processInbox']();}catch{}}}}catch(_0x3291cd){if(_0x3291cd[_0x2350e0(0x130)]===_0x2350e0(0x164))break;this[_0x2350e0(0x101)]('error',_0x3291cd),this[_0x2350e0(0x10f)](_0x2350e0(0x103)+_0x3291cd[_0x2350e0(0x121)]);}if(this[_0x2350e0(0x158)])this[_0x2350e0(0x101)]('disconnected'),this['log'](_0x2350e0(0x151)+_0x376dd6/0x3e8+'s...'),await this['sleep'](_0x376dd6),_0x376dd6=Math[_0x2350e0(0x15f)](_0x376dd6*1.5,0xea60);}}async[a0_0x5f3d88(0x111)](){const _0x13d02a=a0_0x5f3d88;try{let _0x1d3cd6=(await this[_0x13d02a(0x157)](_0x13d02a(0xef),{'alias':this[_0x13d02a(0x14f)],'limit':0xa}))?.[_0x13d02a(0xf3)]||[];for(let _0xfd89c7 of _0x1d3cd6)await this[_0x13d02a(0x157)](_0x13d02a(0x107),{'alias':this[_0x13d02a(0x14f)],'message_id':_0xfd89c7['id']}),this[_0x13d02a(0x10f)]('←\x20'+_0xfd89c7[_0x13d02a(0xe2)]+':\x20'+_0xfd89c7[_0x13d02a(0xf6)][_0x13d02a(0x115)](0x0,0x3c)),this[_0x13d02a(0x101)]('task',_0xfd89c7),this[_0x13d02a(0x101)]('message',_0xfd89c7);}catch(_0x22e031){this[_0x13d02a(0x10f)](_0x13d02a(0xf4)+_0x22e031[_0x13d02a(0x121)]);}}[a0_0x5f3d88(0x10c)](_0x1cf8e6){return new Promise(_0x220e8c=>setTimeout(_0x220e8c,_0x1cf8e6));}}var F=$;export{F as default,$ as CommHub};