@sleep2agi/agent-network 2.3.0-preview.42 → 2.3.0-preview.43

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_0x56022d=a0_0x38ca;(function(_0x4629b9,_0x118604){const _0x54356c=a0_0x38ca,_0x36e29d=_0x4629b9();while(!![]){try{const _0x782cb0=-parseInt(_0x54356c(0xc7))/0x1+parseInt(_0x54356c(0xe0))/0x2+-parseInt(_0x54356c(0x130))/0x3+parseInt(_0x54356c(0xf4))/0x4+parseInt(_0x54356c(0x12a))/0x5+-parseInt(_0x54356c(0x10a))/0x6+parseInt(_0x54356c(0x12b))/0x7*(parseInt(_0x54356c(0xe9))/0x8);if(_0x782cb0===_0x118604)break;else _0x36e29d['push'](_0x36e29d['shift']());}catch(_0x5f59e6){_0x36e29d['push'](_0x36e29d['shift']());}}}(a0_0x5110,0x9ffa8));import{EventEmitter as a0_0x502e16}from'events';import{hostname as a0_0xc59dae}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x45714e,_0x17e0c8)=>(_0x45714e??_0x17e0c8)[a0_0x56022d(0xf3)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x56022d(0x110)](0x0,0xf0);function a0_0x38ca(_0x31ae90,_0x4ae8da){_0x31ae90=_0x31ae90-0xc1;const _0x51105e=a0_0x5110();let _0x38cab4=_0x51105e[_0x31ae90];return _0x38cab4;}function N(_0x50c6fb){const _0x482290=a0_0x56022d;return(_0x50c6fb instanceof Error?_0x50c6fb['message']:String(_0x50c6fb??_0x482290(0x104)))[_0x482290(0xf3)](K,_0x482290(0x11d))[_0x482290(0xf3)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x482290(0x110)](0x0,0xf0);}function O(_0x248b50,_0x4e3665=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x3c39a6=a0_0x56022d;if(_0x4e3665)return JSON[_0x3c39a6(0x111)](_0x248b50);let _0x5aa6b1=L(_0x248b50[_0x3c39a6(0x107)],_0x3c39a6(0xf7)),_0x1fb156=L(_0x248b50[_0x3c39a6(0xee)],_0x3c39a6(0x109)),_0x201c3c=_0x248b50[_0x3c39a6(0xcc)]?_0x3c39a6(0xca)+_0x248b50[_0x3c39a6(0xcc)]+':'+(_0x248b50[_0x3c39a6(0xe1)]??''):'';return _0x3c39a6(0x10b)+_0x248b50['status']+_0x3c39a6(0xc5)+L(_0x248b50[_0x3c39a6(0xc6)],_0x3c39a6(0x125))+_0x3c39a6(0xde)+L(_0x248b50[_0x3c39a6(0x106)],_0x3c39a6(0x125))+'\x20task_id='+_0x1fb156+'\x20parent_task_id='+_0x5aa6b1+_0x3c39a6(0x10d)+L(_0x248b50[_0x3c39a6(0xf2)],_0x3c39a6(0x125))+'\x20transport='+_0x248b50[_0x3c39a6(0x118)]+_0x3c39a6(0x123)+_0x248b50[_0x3c39a6(0x128)]+'\x20lifecycle='+_0x248b50[_0x3c39a6(0x103)]+_0x201c3c;}function U(_0x32fb4b){const _0x2370fd=a0_0x56022d;return{'event':{'sending':_0x2370fd(0xf1),'delivered':_0x2370fd(0xd0),'failed':_0x2370fd(0xd2),'acked':'task.ack','started':_0x2370fd(0xf5),'replied':_0x2370fd(0x11e),'expired':_0x2370fd(0xfb)}[_0x32fb4b['status']],..._0x32fb4b};}function j(_0x1ca6b9){const _0x3df28b=a0_0x56022d;let _0xb824c1=_0x1ca6b9?.['task_id']||_0x1ca6b9?.['message_id']||_0x1ca6b9?.['id'];if(_0xb824c1)return String(_0xb824c1);let _0x597186=_0x1ca6b9?.['content']?.[0x0]?.['text'];if(typeof _0x597186!==_0x3df28b(0x134))return null;try{let _0x1f56e9=JSON[_0x3df28b(0xd1)](_0x597186);return _0x1f56e9?.[_0x3df28b(0xee)]||_0x1f56e9?.[_0x3df28b(0x131)]||_0x1f56e9?.['id']||null;}catch{return null;}}function a0_0x5110(){const _0x3c43a6=['string','/mcp',']\x20[commhub:','content','alias','match','networkId','Bearer\x20','from_session','offline','AbortError','\x20from=','from_alias','878024YsqjrC','completed','call','\x20error=','broadcast','error_code','log','fromAlias','running','task.send.delivered','parse','task.send.failed','CommHub\x20response\x20omitted\x20task_id','task','Authorization','send_task','SSE\x20reconnecting\x20in\x20','report_status','message','missing_task_id','startsWith','error','type','\x20to=','send','1564238VlandM','error_message','token','data:\x20','getReader','get_all_status','abort','reconnectDelay','disconnected','56nmolUy','application/json','disconnect','body','connect','task_id','get_inbox','parentTaskId','task.send.start','network_id','replace','3959424kusEGz','task.started','send_message','<missing>','toTimeString','sseAbort','sleep','task.expired','/events/','resumeId','ack_inbox','read','send_reply','SSE\x20failed:\x20','emit','lifecycle_tracking','unknown\x20error','url','to_alias','parent_task_id','lifecycleTracking','<pending>','7692030ohOZYw','[commhub:task]\x20','application/json,\x20text/event-stream','\x20network_id=','connected','status','slice','stringify','sdk','failed','signal','new_message','min','pop','transport','toString','inbox\x20error:\x20','send_failed','split','[REDACTED]','task.replied','processInbox','heartbeatTimer','new_task','not_tracked','\x20duration_ms=','getAllStatus','<unknown>','connectSSE','SSE\x20error:\x20','duration_ms','CommHub\x20rejected\x20task','597455IvAFON','1911049kIcoyr','now','agent','text/event-stream','text','2961642WGhxWk','message_id','idle','heartbeatInterval'];a0_0x5110=function(){return _0x3c43a6;};return a0_0x5110();}async function X(_0x338711,_0x1fb0ca){const _0xba4b11=a0_0x56022d;let _0x4f3d70=_0x1fb0ca[_0xba4b11(0x12c)]??Date[_0xba4b11(0x12c)],_0x519117=_0x4f3d70(),_0x5af6d0=(_0x28b8fa,_0x523415,_0x3ab226,_0x319dca)=>{const _0x11a92a=_0xba4b11;_0x1fb0ca[_0x11a92a(0xcd)](O(U({'from_alias':_0x338711[_0x11a92a(0xce)],'to_alias':_0x338711['toAlias'],'task_id':_0x523415,'parent_task_id':_0x338711[_0x11a92a(0xf0)],'network_id':_0x338711[_0x11a92a(0x13a)],'transport':_0x338711[_0x11a92a(0x118)],'status':_0x28b8fa,'duration_ms':_0x4f3d70()-_0x519117,'lifecycle_tracking':_0x338711[_0x11a92a(0x108)],..._0x3ab226!==void 0x0?{'error_code':_0x319dca||_0x11a92a(0x11b),'error_message':N(_0x3ab226)}:{}})));};_0x5af6d0('sending',null);try{let _0x2c1b27=await _0x1fb0ca[_0xba4b11(0xdf)](),_0x3063e5=j(_0x2c1b27);if(_0x3063e5)_0x5af6d0('delivered',_0x3063e5);else{if(_0x2c1b27?.['ok']===!0x1||_0x2c1b27?.[_0xba4b11(0xdc)])_0x5af6d0(_0xba4b11(0x113),_0x3063e5,_0x2c1b27?.['error']||_0xba4b11(0x129),'send_rejected');else _0x5af6d0(_0xba4b11(0x113),null,_0xba4b11(0xd3),_0xba4b11(0xda));}return _0x2c1b27;}catch(_0x31ed0b){throw _0x5af6d0(_0xba4b11(0x113),null,_0x31ed0b,_0xba4b11(0x11b)),_0x31ed0b;}}async function Y(_0x5787d1,_0x42af13){const _0x138607=a0_0x56022d;return X({'fromAlias':_0x5787d1[_0x138607(0xce)],'toAlias':_0x5787d1[_0x138607(0x138)],'parentTaskId':_0x5787d1[_0x138607(0xf0)]||null,'networkId':_0x5787d1['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x138607(0x122)},_0x42af13);}class $ extends a0_0x502e16{[a0_0x56022d(0x105)];[a0_0x56022d(0x138)];[a0_0x56022d(0xe2)];[a0_0x56022d(0x12d)];['resumeId'];['heartbeatInterval'];[a0_0x56022d(0xe7)];[a0_0x56022d(0x120)];['sseAbort'];[a0_0x56022d(0xcf)]=!0x1;constructor(_0x39fa05){const _0x4cb79e=a0_0x56022d;super();if(this[_0x4cb79e(0x105)]=_0x39fa05['url'][_0x4cb79e(0xf3)](/\/$/,''),this[_0x4cb79e(0x138)]=_0x39fa05[_0x4cb79e(0x138)],this[_0x4cb79e(0xe2)]=_0x39fa05[_0x4cb79e(0xe2)],this['agent']=_0x39fa05[_0x4cb79e(0x12d)]||_0x4cb79e(0x112),this['resumeId']='sdk-'+_0x39fa05['alias']+'-'+Date[_0x4cb79e(0x12c)]()[_0x4cb79e(0x119)](0x24),this[_0x4cb79e(0x133)]=_0x39fa05[_0x4cb79e(0x133)]??0x2bf20,this[_0x4cb79e(0xe7)]=_0x39fa05[_0x4cb79e(0xe7)]??0xbb8,_0x39fa05['autoConnect']!==!0x1)this[_0x4cb79e(0xed)]();}[a0_0x56022d(0xcd)](_0x5dd81b){const _0x3348fa=a0_0x56022d;console[_0x3348fa(0xcd)]('['+new Date()[_0x3348fa(0xf8)]()[_0x3348fa(0x110)](0x0,0x8)+_0x3348fa(0x136)+this['alias']+']\x20'+_0x5dd81b);}async[a0_0x56022d(0xc9)](_0x12a68b,_0x16dabd){const _0x38ffce=a0_0x56022d;let _0x19f458={'Content-Type':_0x38ffce(0xea),'Accept':_0x38ffce(0x10c)};if(this[_0x38ffce(0xe2)])_0x19f458['Authorization']=_0x38ffce(0xc1)+this[_0x38ffce(0xe2)];let _0x42185f=await(await fetch(this[_0x38ffce(0x105)]+_0x38ffce(0x135),{'method':'POST','headers':_0x19f458,'body':JSON['stringify']({'jsonrpc':'2.0','id':Date[_0x38ffce(0x12c)](),'method':'tools/call','params':{'name':_0x12a68b,'arguments':_0x16dabd}})}))[_0x38ffce(0x12f)](),_0x129c6d=_0x42185f[_0x38ffce(0x139)](/data: (.+)/),_0x497efb=_0x129c6d?JSON[_0x38ffce(0xd1)](_0x129c6d[0x1]):JSON[_0x38ffce(0xd1)](_0x42185f),_0x2ec0d2=_0x497efb?.['result']?.['content']?.[0x0]?.['text'];return _0x2ec0d2?JSON[_0x38ffce(0xd1)](_0x2ec0d2):_0x497efb;}async['connect'](){const _0x38c1c9=a0_0x56022d;if(this[_0x38c1c9(0xcf)])return;this[_0x38c1c9(0xcf)]=!0x0,await this[_0x38c1c9(0x10f)](_0x38c1c9(0x132)),this['log']('registered'),this[_0x38c1c9(0x120)]=setInterval(()=>{const _0x29d8a9=_0x38c1c9;this['status'](_0x29d8a9(0x132))['catch'](_0x1a627d=>this[_0x29d8a9(0xcd)]('heartbeat\x20failed:\x20'+_0x1a627d[_0x29d8a9(0xd9)]));},this[_0x38c1c9(0x133)]),this[_0x38c1c9(0x126)]();}async[a0_0x56022d(0xeb)](){const _0x49bb77=a0_0x56022d;if(this[_0x49bb77(0xcf)]=!0x1,this[_0x49bb77(0xf9)]?.[_0x49bb77(0xe6)](),this[_0x49bb77(0x120)])clearInterval(this[_0x49bb77(0x120)]);await this['status'](_0x49bb77(0xc3))['catch'](()=>{}),this[_0x49bb77(0xcd)](_0x49bb77(0xe8));}async[a0_0x56022d(0xdf)](_0x252a70,_0x3ede2f,_0x2230c9='normal'){const _0x94cc9f=a0_0x56022d;return Y({'alias':_0x252a70,'fromAlias':this[_0x94cc9f(0x138)]},{'log':_0x29e682=>console['log'](_0x29e682),'send':()=>this['call'](_0x94cc9f(0xd6),{'alias':_0x252a70,'task':_0x3ede2f,'priority':_0x2230c9,'from_session':this['alias']})});}async[a0_0x56022d(0xd9)](_0x27aca7,_0x23e956){const _0x2811e8=a0_0x56022d;return this['call'](_0x2811e8(0xf6),{'alias':_0x27aca7,'message':_0x23e956,'from_session':this[_0x2811e8(0x138)]});}async['reply'](_0x44016b,_0xa7499d,_0x31ecda=a0_0x56022d(0xc8)){const _0x22e65e=a0_0x56022d;return this[_0x22e65e(0xc9)](_0x22e65e(0x100),{'in_reply_to':_0x44016b,'text':_0xa7499d,'status':_0x31ecda});}async[a0_0x56022d(0x10f)](_0x534b44,_0x1c7802){const _0x20727f=a0_0x56022d;return this[_0x20727f(0xc9)](_0x20727f(0xd8),{'resume_id':this[_0x20727f(0xfd)],'alias':this[_0x20727f(0x138)],'status':_0x534b44,'server':a0_0xc59dae(),'hostname':a0_0xc59dae(),'agent':this['agent'],'project_dir':process['cwd'](),..._0x1c7802});}async[a0_0x56022d(0x124)](){const _0x221e9b=a0_0x56022d;return this[_0x221e9b(0xc9)](_0x221e9b(0xe5),{});}async[a0_0x56022d(0xcb)](_0x47b586,_0x290357){const _0x57f305=a0_0x56022d;return this[_0x57f305(0xc9)](_0x57f305(0xcb),{'message':_0x47b586,'filter_server':_0x290357?.['server'],'filter_status':_0x290357?.['status']});}async[a0_0x56022d(0x126)](){const _0x456e9d=a0_0x56022d;let _0x3843d0=encodeURIComponent(this['alias']),_0x11a7b0=this[_0x456e9d(0x105)]+_0x456e9d(0xfc)+_0x3843d0,_0x21597e=this[_0x456e9d(0xe7)];while(this[_0x456e9d(0xcf)]){try{this[_0x456e9d(0xf9)]=new AbortController();let _0x5796d7={'Accept':_0x456e9d(0x12e)};if(this[_0x456e9d(0xe2)])_0x5796d7[_0x456e9d(0xd5)]=_0x456e9d(0xc1)+this['token'];let _0x1206e3=await fetch(_0x11a7b0,{'headers':_0x5796d7,'signal':this[_0x456e9d(0xf9)][_0x456e9d(0x114)]});if(!_0x1206e3['ok']||!_0x1206e3[_0x456e9d(0xec)]){this[_0x456e9d(0xcd)](_0x456e9d(0x101)+_0x1206e3['status']),await this['sleep'](_0x21597e),_0x21597e=Math[_0x456e9d(0x116)](_0x21597e*1.5,0xea60);continue;}_0x21597e=this[_0x456e9d(0xe7)];let _0x3954c0=_0x1206e3['body'][_0x456e9d(0xe4)](),_0x1cac02=new TextDecoder(),_0x4ca4fd='';while(this[_0x456e9d(0xcf)]){let {done:_0x2752df,value:_0x729eea}=await _0x3954c0[_0x456e9d(0xff)]();if(_0x2752df)break;_0x4ca4fd+=_0x1cac02['decode'](_0x729eea,{'stream':!0x0});let _0x103e41=_0x4ca4fd[_0x456e9d(0x11c)]('\x0a');_0x4ca4fd=_0x103e41[_0x456e9d(0x117)]()||'';for(let _0x6f0720 of _0x103e41){if(!_0x6f0720[_0x456e9d(0xdb)](_0x456e9d(0xe3)))continue;try{let _0x24c24e=JSON['parse'](_0x6f0720[_0x456e9d(0x110)](0x6));if(_0x24c24e['type']===_0x456e9d(0x10e)){this[_0x456e9d(0xcd)]('SSE\x20connected'),this[_0x456e9d(0x102)](_0x456e9d(0x10e));continue;}if(_0x24c24e['type']===_0x456e9d(0x121)||_0x24c24e[_0x456e9d(0xdd)]===_0x456e9d(0x115)||_0x24c24e[_0x456e9d(0xdd)]===_0x456e9d(0xcb))await this[_0x456e9d(0x11f)]();}catch{}}}}catch(_0x323866){if(_0x323866['name']===_0x456e9d(0xc4))break;this['emit']('error',_0x323866),this[_0x456e9d(0xcd)](_0x456e9d(0x127)+_0x323866[_0x456e9d(0xd9)]);}if(this[_0x456e9d(0xcf)])this[_0x456e9d(0x102)](_0x456e9d(0xe8)),this[_0x456e9d(0xcd)](_0x456e9d(0xd7)+_0x21597e/0x3e8+'s...'),await this['sleep'](_0x21597e),_0x21597e=Math[_0x456e9d(0x116)](_0x21597e*1.5,0xea60);}}async[a0_0x56022d(0x11f)](){const _0x5a817e=a0_0x56022d;try{let _0x18f7ab=(await this['call'](_0x5a817e(0xef),{'alias':this[_0x5a817e(0x138)],'limit':0xa}))?.['messages']||[];for(let _0x483526 of _0x18f7ab)await this[_0x5a817e(0xc9)](_0x5a817e(0xfe),{'alias':this[_0x5a817e(0x138)],'message_id':_0x483526['id']}),this[_0x5a817e(0xcd)]('←\x20'+_0x483526[_0x5a817e(0xc2)]+':\x20'+_0x483526[_0x5a817e(0x137)][_0x5a817e(0x110)](0x0,0x3c)),this[_0x5a817e(0x102)](_0x5a817e(0xd4),_0x483526),this['emit']('message',_0x483526);}catch(_0x1ee5d9){this[_0x5a817e(0xcd)](_0x5a817e(0x11a)+_0x1ee5d9[_0x5a817e(0xd9)]);}}[a0_0x56022d(0xfa)](_0x36e69f){return new Promise(_0x5dded4=>setTimeout(_0x5dded4,_0x36e69f));}}var F=$;export{F as default,$ as CommHub};
1
+ const a0_0x2f352f=a0_0x5124;(function(_0x5322a3,_0x2af4e8){const _0x598ce0=a0_0x5124,_0x5654cc=_0x5322a3();while(!![]){try{const _0x6cb459=-parseInt(_0x598ce0(0x169))/0x1+parseInt(_0x598ce0(0x18e))/0x2*(parseInt(_0x598ce0(0x18d))/0x3)+-parseInt(_0x598ce0(0x16e))/0x4+-parseInt(_0x598ce0(0x181))/0x5+parseInt(_0x598ce0(0x147))/0x6*(parseInt(_0x598ce0(0x13c))/0x7)+parseInt(_0x598ce0(0x12f))/0x8+parseInt(_0x598ce0(0x195))/0x9;if(_0x6cb459===_0x2af4e8)break;else _0x5654cc['push'](_0x5654cc['shift']());}catch(_0x21337b){_0x5654cc['push'](_0x5654cc['shift']());}}}(a0_0xab51,0x39e97));import{EventEmitter as a0_0x250d64}from'events';import{hostname as a0_0x5f39bf}from'os';function a0_0x5124(_0x304534,_0x4fb9e3){_0x304534=_0x304534-0x125;const _0xab51b0=a0_0xab51();let _0x512471=_0xab51b0[_0x304534];return _0x512471;}var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x2ba7d3,_0x60a6e2)=>(_0x2ba7d3??_0x60a6e2)[a0_0x2f352f(0x141)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[a0_0x2f352f(0x179)](0x0,0xf0);function N(_0x2cba3a){const _0x32decb=a0_0x2f352f;return(_0x2cba3a instanceof Error?_0x2cba3a[_0x32decb(0x18f)]:String(_0x2cba3a??_0x32decb(0x13b)))['replace'](K,_0x32decb(0x12d))[_0x32decb(0x141)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x32decb(0x179)](0x0,0xf0);}function a0_0xab51(){const _0x3b9d02=['replace','toTimeString','task.send.start','processInbox','<unknown>','sending','24OwFUcn','\x20task_id=','lifecycle_tracking','log','catch','s...','network_id','connectSSE','type','failed','parse','error','text/event-stream','token','abort','send_task',']\x20[commhub:','CommHub\x20response\x20omitted\x20task_id','emit','call','send','read','server','SSE\x20failed:\x20','\x20from=','heartbeat\x20failed:\x20','parentTaskId','2.0','task.replied','autoConnect','disconnected','error_message','decode','completed','283405FRGtCh','broadcast','<pending>','mcp_http','missing_task_id','541068oJIoKH','/events/','normal','task.send.delivered','alias','startsWith','connect','AbortError','get_inbox','from_session','string','slice','new_task','report_status','SSE\x20error:\x20','send_reply','task','heartbeatTimer','sdk','2023595HaQdmL','connected','tools/call','agent','running','\x20network_id=','to_alias','parent_task_id','SSE\x20connected','signal','name','reconnectDelay','6QSltkM','110056CSspmM','message','not_tracked','stringify','send_message','application/json','reply','7974189uHlXZu','\x20to=','task_id','CommHub\x20rejected\x20task','status','Bearer\x20','sseAbort','body','task.ack','getAllStatus','result','get_all_status','[commhub:task]\x20','now','error_code','networkId','heartbeatInterval','pop','idle','registered','ack_inbox','send_failed','match','split','[REDACTED]','\x20lifecycle=','74120zQtgFu','transport','text','resumeId','content','sleep','\x20parent_task_id=','SSE\x20reconnecting\x20in\x20','data:\x20','cwd','task.started','/mcp','unknown\x20error','96698yuVdtY','url','fromAlias','min','\x20transport='];a0_0xab51=function(){return _0x3b9d02;};return a0_0xab51();}function O(_0x13c579,_0x11f28c=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x5c9387=a0_0x2f352f;if(_0x11f28c)return JSON['stringify'](_0x13c579);let _0x76accb=L(_0x13c579[_0x5c9387(0x188)],'<missing>'),_0x20da8b=L(_0x13c579['task_id'],_0x5c9387(0x16b)),_0x9c1fce=_0x13c579[_0x5c9387(0x1a3)]?'\x20error='+_0x13c579[_0x5c9387(0x1a3)]+':'+(_0x13c579[_0x5c9387(0x166)]??''):'';return _0x5c9387(0x1a1)+_0x13c579['status']+_0x5c9387(0x15f)+L(_0x13c579['from_alias'],_0x5c9387(0x145))+_0x5c9387(0x196)+L(_0x13c579[_0x5c9387(0x187)],_0x5c9387(0x145))+_0x5c9387(0x148)+_0x20da8b+_0x5c9387(0x135)+_0x76accb+_0x5c9387(0x186)+L(_0x13c579[_0x5c9387(0x14d)],_0x5c9387(0x145))+_0x5c9387(0x140)+_0x13c579[_0x5c9387(0x130)]+'\x20duration_ms='+_0x13c579['duration_ms']+_0x5c9387(0x12e)+_0x13c579[_0x5c9387(0x149)]+_0x9c1fce;}function U(_0x3f41f1){const _0x2536b8=a0_0x2f352f;return{'event':{'sending':_0x2536b8(0x143),'delivered':_0x2536b8(0x171),'failed':'task.send.failed','acked':_0x2536b8(0x19d),'started':_0x2536b8(0x139),'replied':_0x2536b8(0x163),'expired':'task.expired'}[_0x3f41f1[_0x2536b8(0x199)]],..._0x3f41f1};}function j(_0x1a0dc3){const _0x817e31=a0_0x2f352f;let _0x44fc44=_0x1a0dc3?.[_0x817e31(0x197)]||_0x1a0dc3?.['message_id']||_0x1a0dc3?.['id'];if(_0x44fc44)return String(_0x44fc44);let _0x190fbc=_0x1a0dc3?.['content']?.[0x0]?.[_0x817e31(0x131)];if(typeof _0x190fbc!==_0x817e31(0x178))return null;try{let _0x1dd041=JSON[_0x817e31(0x151)](_0x190fbc);return _0x1dd041?.[_0x817e31(0x197)]||_0x1dd041?.['message_id']||_0x1dd041?.['id']||null;}catch{return null;}}async function X(_0x599cbb,_0x549076){const _0x32f9fe=a0_0x2f352f;let _0x29f670=_0x549076[_0x32f9fe(0x1a2)]??Date[_0x32f9fe(0x1a2)],_0x423360=_0x29f670(),_0x288558=(_0x53841d,_0x1a021c,_0x30cad3,_0x2ec669)=>{const _0x42c272=_0x32f9fe;_0x549076[_0x42c272(0x14a)](O(U({'from_alias':_0x599cbb[_0x42c272(0x13e)],'to_alias':_0x599cbb['toAlias'],'task_id':_0x1a021c,'parent_task_id':_0x599cbb[_0x42c272(0x161)],'network_id':_0x599cbb[_0x42c272(0x1a4)],'transport':_0x599cbb[_0x42c272(0x130)],'status':_0x53841d,'duration_ms':_0x29f670()-_0x423360,'lifecycle_tracking':_0x599cbb['lifecycleTracking'],..._0x30cad3!==void 0x0?{'error_code':_0x2ec669||'send_failed','error_message':N(_0x30cad3)}:{}})));};_0x288558(_0x32f9fe(0x146),null);try{let _0x2fccbe=await _0x549076[_0x32f9fe(0x15b)](),_0x3b957f=j(_0x2fccbe);if(_0x3b957f)_0x288558('delivered',_0x3b957f);else{if(_0x2fccbe?.['ok']===!0x1||_0x2fccbe?.['error'])_0x288558(_0x32f9fe(0x150),_0x3b957f,_0x2fccbe?.[_0x32f9fe(0x152)]||_0x32f9fe(0x198),'send_rejected');else _0x288558('failed',null,_0x32f9fe(0x158),_0x32f9fe(0x16d));}return _0x2fccbe;}catch(_0x17ede5){throw _0x288558(_0x32f9fe(0x150),null,_0x17ede5,_0x32f9fe(0x12a)),_0x17ede5;}}async function Y(_0x32d69b,_0x39bd39){const _0x17f6d5=a0_0x2f352f;return X({'fromAlias':_0x32d69b[_0x17f6d5(0x13e)],'toAlias':_0x32d69b[_0x17f6d5(0x172)],'parentTaskId':_0x32d69b[_0x17f6d5(0x161)]||null,'networkId':_0x32d69b[_0x17f6d5(0x1a4)]||null,'transport':_0x17f6d5(0x16c),'lifecycleTracking':_0x17f6d5(0x190)},_0x39bd39);}class $ extends a0_0x250d64{[a0_0x2f352f(0x13d)];[a0_0x2f352f(0x172)];[a0_0x2f352f(0x154)];[a0_0x2f352f(0x184)];[a0_0x2f352f(0x132)];[a0_0x2f352f(0x125)];['reconnectDelay'];[a0_0x2f352f(0x17f)];['sseAbort'];[a0_0x2f352f(0x185)]=!0x1;constructor(_0x2f315d){const _0x1d4b1a=a0_0x2f352f;super();if(this[_0x1d4b1a(0x13d)]=_0x2f315d[_0x1d4b1a(0x13d)][_0x1d4b1a(0x141)](/\/$/,''),this[_0x1d4b1a(0x172)]=_0x2f315d[_0x1d4b1a(0x172)],this[_0x1d4b1a(0x154)]=_0x2f315d[_0x1d4b1a(0x154)],this['agent']=_0x2f315d[_0x1d4b1a(0x184)]||_0x1d4b1a(0x180),this['resumeId']='sdk-'+_0x2f315d[_0x1d4b1a(0x172)]+'-'+Date[_0x1d4b1a(0x1a2)]()['toString'](0x24),this[_0x1d4b1a(0x125)]=_0x2f315d[_0x1d4b1a(0x125)]??0x2bf20,this[_0x1d4b1a(0x18c)]=_0x2f315d[_0x1d4b1a(0x18c)]??0xbb8,_0x2f315d[_0x1d4b1a(0x164)]!==!0x1)this['connect']();}['log'](_0x4237c5){const _0x17fd54=a0_0x2f352f;console[_0x17fd54(0x14a)]('['+new Date()[_0x17fd54(0x142)]()[_0x17fd54(0x179)](0x0,0x8)+_0x17fd54(0x157)+this[_0x17fd54(0x172)]+']\x20'+_0x4237c5);}async['call'](_0x21c3d0,_0x5a243a){const _0x3eada9=a0_0x2f352f;let _0x292040={'Content-Type':_0x3eada9(0x193),'Accept':'application/json,\x20text/event-stream'};if(this[_0x3eada9(0x154)])_0x292040['Authorization']=_0x3eada9(0x19a)+this[_0x3eada9(0x154)];let _0xae887d=await(await fetch(this['url']+_0x3eada9(0x13a),{'method':'POST','headers':_0x292040,'body':JSON[_0x3eada9(0x191)]({'jsonrpc':_0x3eada9(0x162),'id':Date[_0x3eada9(0x1a2)](),'method':_0x3eada9(0x183),'params':{'name':_0x21c3d0,'arguments':_0x5a243a}})}))[_0x3eada9(0x131)](),_0x580008=_0xae887d[_0x3eada9(0x12b)](/data: (.+)/),_0x33806c=_0x580008?JSON[_0x3eada9(0x151)](_0x580008[0x1]):JSON['parse'](_0xae887d),_0x105b5f=_0x33806c?.[_0x3eada9(0x19f)]?.[_0x3eada9(0x133)]?.[0x0]?.[_0x3eada9(0x131)];return _0x105b5f?JSON[_0x3eada9(0x151)](_0x105b5f):_0x33806c;}async[a0_0x2f352f(0x174)](){const _0x1806d8=a0_0x2f352f;if(this['running'])return;this[_0x1806d8(0x185)]=!0x0,await this[_0x1806d8(0x199)]('idle'),this[_0x1806d8(0x14a)](_0x1806d8(0x128)),this[_0x1806d8(0x17f)]=setInterval(()=>{const _0x1854cc=_0x1806d8;this[_0x1854cc(0x199)](_0x1854cc(0x127))[_0x1854cc(0x14b)](_0x3fff56=>this[_0x1854cc(0x14a)](_0x1854cc(0x160)+_0x3fff56[_0x1854cc(0x18f)]));},this['heartbeatInterval']),this[_0x1806d8(0x14e)]();}async['disconnect'](){const _0x24b178=a0_0x2f352f;if(this[_0x24b178(0x185)]=!0x1,this[_0x24b178(0x19b)]?.[_0x24b178(0x155)](),this[_0x24b178(0x17f)])clearInterval(this[_0x24b178(0x17f)]);await this['status']('offline')[_0x24b178(0x14b)](()=>{}),this[_0x24b178(0x14a)](_0x24b178(0x165));}async[a0_0x2f352f(0x15b)](_0x56c25b,_0x5194f3,_0x1395c3=a0_0x2f352f(0x170)){const _0x579c7d=a0_0x2f352f;return Y({'alias':_0x56c25b,'fromAlias':this['alias']},{'log':_0xf88e9b=>console['log'](_0xf88e9b),'send':()=>this['call'](_0x579c7d(0x156),{'alias':_0x56c25b,'task':_0x5194f3,'priority':_0x1395c3,'from_session':this[_0x579c7d(0x172)]})});}async[a0_0x2f352f(0x18f)](_0x55a2f4,_0x1301b1){const _0x59ccb7=a0_0x2f352f;return this['call'](_0x59ccb7(0x192),{'alias':_0x55a2f4,'message':_0x1301b1,'from_session':this[_0x59ccb7(0x172)]});}async[a0_0x2f352f(0x194)](_0x26c9c3,_0x207af6,_0x181df0=a0_0x2f352f(0x168)){const _0x13acc2=a0_0x2f352f;return this['call'](_0x13acc2(0x17d),{'in_reply_to':_0x26c9c3,'text':_0x207af6,'status':_0x181df0});}async[a0_0x2f352f(0x199)](_0x3d0d26,_0x127868){const _0x59266b=a0_0x2f352f;return this['call'](_0x59266b(0x17b),{'resume_id':this[_0x59266b(0x132)],'alias':this[_0x59266b(0x172)],'status':_0x3d0d26,'server':a0_0x5f39bf(),'hostname':a0_0x5f39bf(),'agent':this['agent'],'project_dir':process[_0x59266b(0x138)](),..._0x127868});}async[a0_0x2f352f(0x19e)](){const _0x104267=a0_0x2f352f;return this[_0x104267(0x15a)](_0x104267(0x1a0),{});}async['broadcast'](_0x467140,_0xf53abf){const _0x5e5cc0=a0_0x2f352f;return this[_0x5e5cc0(0x15a)](_0x5e5cc0(0x16a),{'message':_0x467140,'filter_server':_0xf53abf?.[_0x5e5cc0(0x15d)],'filter_status':_0xf53abf?.['status']});}async[a0_0x2f352f(0x14e)](){const _0x2c33e2=a0_0x2f352f;let _0x16f188=encodeURIComponent(this['alias']),_0x989910=this[_0x2c33e2(0x13d)]+_0x2c33e2(0x16f)+_0x16f188,_0x525266=this[_0x2c33e2(0x18c)];while(this[_0x2c33e2(0x185)]){try{this[_0x2c33e2(0x19b)]=new AbortController();let _0x2332ba={'Accept':_0x2c33e2(0x153)};if(this[_0x2c33e2(0x154)])_0x2332ba['Authorization']=_0x2c33e2(0x19a)+this['token'];let _0x235351=await fetch(_0x989910,{'headers':_0x2332ba,'signal':this[_0x2c33e2(0x19b)][_0x2c33e2(0x18a)]});if(!_0x235351['ok']||!_0x235351['body']){this[_0x2c33e2(0x14a)](_0x2c33e2(0x15e)+_0x235351[_0x2c33e2(0x199)]),await this['sleep'](_0x525266),_0x525266=Math[_0x2c33e2(0x13f)](_0x525266*1.5,0xea60);continue;}_0x525266=this[_0x2c33e2(0x18c)];let _0x171bb3=_0x235351[_0x2c33e2(0x19c)]['getReader'](),_0x1823bb=new TextDecoder(),_0x4790b2='';while(this['running']){let {done:_0x193d14,value:_0x3ab86e}=await _0x171bb3[_0x2c33e2(0x15c)]();if(_0x193d14)break;_0x4790b2+=_0x1823bb[_0x2c33e2(0x167)](_0x3ab86e,{'stream':!0x0});let _0x385b33=_0x4790b2[_0x2c33e2(0x12c)]('\x0a');_0x4790b2=_0x385b33[_0x2c33e2(0x126)]()||'';for(let _0x296318 of _0x385b33){if(!_0x296318[_0x2c33e2(0x173)](_0x2c33e2(0x137)))continue;try{let _0x222815=JSON[_0x2c33e2(0x151)](_0x296318[_0x2c33e2(0x179)](0x6));if(_0x222815[_0x2c33e2(0x14f)]===_0x2c33e2(0x182)){this[_0x2c33e2(0x14a)](_0x2c33e2(0x189)),this[_0x2c33e2(0x159)](_0x2c33e2(0x182));continue;}if(_0x222815['type']===_0x2c33e2(0x17a)||_0x222815[_0x2c33e2(0x14f)]==='new_message'||_0x222815['type']==='broadcast')await this[_0x2c33e2(0x144)]();}catch{}}}}catch(_0x443c13){if(_0x443c13[_0x2c33e2(0x18b)]===_0x2c33e2(0x175))break;this['emit'](_0x2c33e2(0x152),_0x443c13),this['log'](_0x2c33e2(0x17c)+_0x443c13[_0x2c33e2(0x18f)]);}if(this[_0x2c33e2(0x185)])this[_0x2c33e2(0x159)](_0x2c33e2(0x165)),this[_0x2c33e2(0x14a)](_0x2c33e2(0x136)+_0x525266/0x3e8+_0x2c33e2(0x14c)),await this['sleep'](_0x525266),_0x525266=Math[_0x2c33e2(0x13f)](_0x525266*1.5,0xea60);}}async[a0_0x2f352f(0x144)](){const _0x3620a1=a0_0x2f352f;try{let _0x295ec4=(await this['call'](_0x3620a1(0x176),{'alias':this['alias'],'limit':0xa}))?.['messages']||[];for(let _0x1f380d of _0x295ec4)await this[_0x3620a1(0x15a)](_0x3620a1(0x129),{'alias':this[_0x3620a1(0x172)],'message_id':_0x1f380d['id']}),this[_0x3620a1(0x14a)]('←\x20'+_0x1f380d[_0x3620a1(0x177)]+':\x20'+_0x1f380d[_0x3620a1(0x133)][_0x3620a1(0x179)](0x0,0x3c)),this[_0x3620a1(0x159)](_0x3620a1(0x17e),_0x1f380d),this[_0x3620a1(0x159)]('message',_0x1f380d);}catch(_0x3bf28e){this[_0x3620a1(0x14a)]('inbox\x20error:\x20'+_0x3bf28e[_0x3620a1(0x18f)]);}}[a0_0x2f352f(0x134)](_0x4b61af){return new Promise(_0x560066=>setTimeout(_0x560066,_0x4b61af));}}var F=$;export{F as default,$ as CommHub};
@@ -0,0 +1,13 @@
1
+ export type CopresenceThreadPlan = {
2
+ method: "thread/resume";
3
+ params: {
4
+ threadId: string;
5
+ };
6
+ bootstrap: false;
7
+ } | {
8
+ method: "thread/start";
9
+ params: Record<string, never>;
10
+ bootstrap: true;
11
+ };
12
+ /** Restarting a node must preserve its conversation; only a virgin node starts one. */
13
+ export declare function copresenceThreadPlan(storedThreadId?: string): CopresenceThreadPlan;