@sleep2agi/agent-network 2.3.0-preview.123 → 2.3.0-preview.126

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_0x47b98e=a0_0x3421;(function(_0x2c41b7,_0x150036){const _0x1fad7d=a0_0x3421,_0x3f2fcc=_0x2c41b7();while(!![]){try{const _0x35aa90=-parseInt(_0x1fad7d(0x202))/0x1*(parseInt(_0x1fad7d(0x187))/0x2)+-parseInt(_0x1fad7d(0x1b2))/0x3+parseInt(_0x1fad7d(0x1b9))/0x4+parseInt(_0x1fad7d(0x1d7))/0x5*(-parseInt(_0x1fad7d(0x1dc))/0x6)+-parseInt(_0x1fad7d(0x1c6))/0x7*(-parseInt(_0x1fad7d(0x1a0))/0x8)+-parseInt(_0x1fad7d(0x193))/0x9*(parseInt(_0x1fad7d(0x1d4))/0xa)+parseInt(_0x1fad7d(0x203))/0xb;if(_0x35aa90===_0x150036)break;else _0x3f2fcc['push'](_0x3f2fcc['shift']());}catch(_0x53a201){_0x3f2fcc['push'](_0x3f2fcc['shift']());}}}(a0_0xbb26,0x5b0e8));import{EventEmitter as a0_0x1389fb}from'events';import{hostname as a0_0x15db84}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x4dee4b,_0x49cc06)=>(_0x4dee4b??_0x49cc06)[a0_0x47b98e(0x186)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0x3516ab){const _0x31f282=a0_0x47b98e;return(_0x3516ab instanceof Error?_0x3516ab[_0x31f282(0x1fa)]:String(_0x3516ab??_0x31f282(0x19d)))['replace'](K,_0x31f282(0x1cc))[_0x31f282(0x186)](/[\r\n\x00-\x1f\x7f]/g,'\x20')[_0x31f282(0x1b7)](0x0,0xf0);}function O(_0x5a1591,_0x2f6cd6=process.env.ANET_TASK_TRACE_FORMAT==='json'){const _0x3fcf4a=a0_0x47b98e;if(_0x2f6cd6)return JSON[_0x3fcf4a(0x1de)](_0x5a1591);let _0x429fc5=L(_0x5a1591[_0x3fcf4a(0x1e6)],_0x3fcf4a(0x1f6)),_0x28b2bd=L(_0x5a1591[_0x3fcf4a(0x1bc)],_0x3fcf4a(0x201)),_0x5a4b49=_0x5a1591[_0x3fcf4a(0x1ad)]?_0x3fcf4a(0x1c5)+_0x5a1591[_0x3fcf4a(0x1ad)]+':'+(_0x5a1591[_0x3fcf4a(0x18e)]??''):'';return _0x3fcf4a(0x1fd)+_0x5a1591['status']+_0x3fcf4a(0x1ab)+L(_0x5a1591[_0x3fcf4a(0x1c3)],'<unknown>')+_0x3fcf4a(0x1c2)+L(_0x5a1591[_0x3fcf4a(0x192)],_0x3fcf4a(0x1ec))+_0x3fcf4a(0x1ff)+_0x28b2bd+_0x3fcf4a(0x1d1)+_0x429fc5+_0x3fcf4a(0x1b3)+L(_0x5a1591[_0x3fcf4a(0x1b5)],_0x3fcf4a(0x1ec))+_0x3fcf4a(0x18b)+_0x5a1591[_0x3fcf4a(0x1f0)]+'\x20duration_ms='+_0x5a1591['duration_ms']+_0x3fcf4a(0x19c)+_0x5a1591[_0x3fcf4a(0x1fc)]+_0x5a4b49;}function a0_0xbb26(){const _0x1ea477=['407973AIkmqc','\x20network_id=','AbortError','network_id','ack_inbox','slice','read','2607096LXWUgP','connected','server','task_id','autoConnect','text/event-stream','token','emit','tools/call','\x20to=','from_alias','call','\x20error=','7poevpF','min','task.started','match','resumeId','s...','[REDACTED]','parse','heartbeatInterval','SSE\x20failed:\x20','delivered','\x20parent_task_id=','getReader','name','3026710kwmGwW','report_status','sdk-','5RbhOxr','sleep','inbox\x20error:\x20','send_task','sending','4264098NRTPtm','text','stringify','agent','not_tracked','now','type','error','parentTaskId','get_inbox','parent_task_id','toTimeString','sseAbort','split','send','new_task','<unknown>','connect','2.0','CommHub\x20rejected\x20task','transport','heartbeatTimer','idle','connectSSE','data:\x20','fromAlias','<missing>','signal','/events/','get_all_status','message','Authorization','lifecycle_tracking','[commhub:task]\x20','SSE\x20error:\x20','\x20task_id=','send_failed','<pending>','1qOrRjK','17481882mYYenJ','log','heartbeat\x20failed:\x20','replace','1485538zwTCEk','task.send.failed','missing_task_id','registered','\x20transport=','CommHub\x20response\x20omitted\x20task_id','reply','error_message','normal','disconnect','disconnected','to_alias','9jYnDjA','cwd','SSE\x20connected','running','POST','send_rejected','alias','networkId','url','\x20lifecycle=','unknown\x20error','catch','broadcast','192368CsAVnr','task.ack','application/json,\x20text/event-stream','task.send.delivered','from_session','Bearer\x20','status','lifecycleTracking','reconnectDelay','toAlias','body','\x20from=','abort','error_code','send_message','content','task.expired','pop'];a0_0xbb26=function(){return _0x1ea477;};return a0_0xbb26();}function U(_0xb48fd5){const _0x1e5217=a0_0x47b98e;return{'event':{'sending':'task.send.start','delivered':_0x1e5217(0x1a3),'failed':_0x1e5217(0x188),'acked':_0x1e5217(0x1a1),'started':_0x1e5217(0x1c8),'replied':'task.replied','expired':_0x1e5217(0x1b0)}[_0xb48fd5[_0x1e5217(0x1a6)]],..._0xb48fd5};}function j(_0x1d47c8){const _0x3cc32c=a0_0x47b98e;let _0x1e222d=_0x1d47c8?.[_0x3cc32c(0x1bc)]||_0x1d47c8?.['message_id']||_0x1d47c8?.['id'];if(_0x1e222d)return String(_0x1e222d);let _0x56ccec=_0x1d47c8?.[_0x3cc32c(0x1af)]?.[0x0]?.[_0x3cc32c(0x1dd)];if(typeof _0x56ccec!=='string')return null;try{let _0x3b1954=JSON[_0x3cc32c(0x1cd)](_0x56ccec);return _0x3b1954?.[_0x3cc32c(0x1bc)]||_0x3b1954?.['message_id']||_0x3b1954?.['id']||null;}catch{return null;}}async function X(_0x255c5c,_0x43c52a){const _0x7a9854=a0_0x47b98e;let _0x212472=_0x43c52a[_0x7a9854(0x1e1)]??Date[_0x7a9854(0x1e1)],_0x4c9925=_0x212472(),_0x1f2f47=(_0x535f72,_0x8d88f8,_0x4ae0cc,_0x214eee)=>{const _0x43e640=_0x7a9854;_0x43c52a['log'](O(U({'from_alias':_0x255c5c[_0x43e640(0x1f5)],'to_alias':_0x255c5c[_0x43e640(0x1a9)],'task_id':_0x8d88f8,'parent_task_id':_0x255c5c[_0x43e640(0x1e4)],'network_id':_0x255c5c[_0x43e640(0x19a)],'transport':_0x255c5c[_0x43e640(0x1f0)],'status':_0x535f72,'duration_ms':_0x212472()-_0x4c9925,'lifecycle_tracking':_0x255c5c[_0x43e640(0x1a7)],..._0x4ae0cc!==void 0x0?{'error_code':_0x214eee||'send_failed','error_message':N(_0x4ae0cc)}:{}})));};_0x1f2f47(_0x7a9854(0x1db),null);try{let _0x22fd77=await _0x43c52a[_0x7a9854(0x1ea)](),_0x3faaf6=j(_0x22fd77);if(_0x3faaf6)_0x1f2f47(_0x7a9854(0x1d0),_0x3faaf6);else{if(_0x22fd77?.['ok']===!0x1||_0x22fd77?.[_0x7a9854(0x1e3)])_0x1f2f47('failed',_0x3faaf6,_0x22fd77?.['error']||_0x7a9854(0x1ef),_0x7a9854(0x198));else _0x1f2f47('failed',null,_0x7a9854(0x18c),_0x7a9854(0x189));}return _0x22fd77;}catch(_0x5930bb){throw _0x1f2f47('failed',null,_0x5930bb,_0x7a9854(0x200)),_0x5930bb;}}async function Y(_0xa2021,_0x4efd20){const _0x449f8b=a0_0x47b98e;return X({'fromAlias':_0xa2021['fromAlias'],'toAlias':_0xa2021[_0x449f8b(0x199)],'parentTaskId':_0xa2021[_0x449f8b(0x1e4)]||null,'networkId':_0xa2021['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x449f8b(0x1e0)},_0x4efd20);}class $ extends a0_0x1389fb{[a0_0x47b98e(0x19b)];[a0_0x47b98e(0x199)];[a0_0x47b98e(0x1bf)];[a0_0x47b98e(0x1df)];['resumeId'];['heartbeatInterval'];[a0_0x47b98e(0x1a8)];[a0_0x47b98e(0x1f1)];[a0_0x47b98e(0x1e8)];['running']=!0x1;constructor(_0x5d63f7){const _0x2d2765=a0_0x47b98e;super();if(this[_0x2d2765(0x19b)]=_0x5d63f7[_0x2d2765(0x19b)][_0x2d2765(0x186)](/\/$/,''),this[_0x2d2765(0x199)]=_0x5d63f7[_0x2d2765(0x199)],this[_0x2d2765(0x1bf)]=_0x5d63f7[_0x2d2765(0x1bf)],this[_0x2d2765(0x1df)]=_0x5d63f7[_0x2d2765(0x1df)]||'sdk',this[_0x2d2765(0x1ca)]=_0x2d2765(0x1d6)+_0x5d63f7[_0x2d2765(0x199)]+'-'+Date[_0x2d2765(0x1e1)]()['toString'](0x24),this[_0x2d2765(0x1ce)]=_0x5d63f7[_0x2d2765(0x1ce)]??0x2bf20,this['reconnectDelay']=_0x5d63f7[_0x2d2765(0x1a8)]??0xbb8,_0x5d63f7[_0x2d2765(0x1bd)]!==!0x1)this[_0x2d2765(0x1ed)]();}[a0_0x47b98e(0x204)](_0x3e8d85){const _0x18627d=a0_0x47b98e;console[_0x18627d(0x204)]('['+new Date()[_0x18627d(0x1e7)]()[_0x18627d(0x1b7)](0x0,0x8)+']\x20[commhub:'+this[_0x18627d(0x199)]+']\x20'+_0x3e8d85);}async[a0_0x47b98e(0x1c4)](_0x3a8de4,_0x516ad1){const _0x5360ff=a0_0x47b98e;let _0x2b2309={'Content-Type':'application/json','Accept':_0x5360ff(0x1a2)};if(this[_0x5360ff(0x1bf)])_0x2b2309[_0x5360ff(0x1fb)]=_0x5360ff(0x1a5)+this[_0x5360ff(0x1bf)];let _0x4d6135=await(await fetch(this[_0x5360ff(0x19b)]+'/mcp',{'method':_0x5360ff(0x197),'headers':_0x2b2309,'body':JSON[_0x5360ff(0x1de)]({'jsonrpc':_0x5360ff(0x1ee),'id':Date[_0x5360ff(0x1e1)](),'method':_0x5360ff(0x1c1),'params':{'name':_0x3a8de4,'arguments':_0x516ad1}})}))[_0x5360ff(0x1dd)](),_0x1fdf1e=_0x4d6135[_0x5360ff(0x1c9)](/data: (.+)/),_0x58b208=_0x1fdf1e?JSON[_0x5360ff(0x1cd)](_0x1fdf1e[0x1]):JSON[_0x5360ff(0x1cd)](_0x4d6135),_0x4e1a00=_0x58b208?.['result']?.['content']?.[0x0]?.['text'];return _0x4e1a00?JSON[_0x5360ff(0x1cd)](_0x4e1a00):_0x58b208;}async[a0_0x47b98e(0x1ed)](){const _0x2e5480=a0_0x47b98e;if(this['running'])return;this[_0x2e5480(0x196)]=!0x0,await this[_0x2e5480(0x1a6)](_0x2e5480(0x1f2)),this[_0x2e5480(0x204)](_0x2e5480(0x18a)),this[_0x2e5480(0x1f1)]=setInterval(()=>{const _0x2b3255=_0x2e5480;this['status']('idle')[_0x2b3255(0x19e)](_0x22f50d=>this[_0x2b3255(0x204)](_0x2b3255(0x185)+_0x22f50d[_0x2b3255(0x1fa)]));},this['heartbeatInterval']),this[_0x2e5480(0x1f3)]();}async[a0_0x47b98e(0x190)](){const _0x6d41d4=a0_0x47b98e;if(this[_0x6d41d4(0x196)]=!0x1,this[_0x6d41d4(0x1e8)]?.[_0x6d41d4(0x1ac)](),this[_0x6d41d4(0x1f1)])clearInterval(this[_0x6d41d4(0x1f1)]);await this[_0x6d41d4(0x1a6)]('offline')[_0x6d41d4(0x19e)](()=>{}),this[_0x6d41d4(0x204)](_0x6d41d4(0x191));}async[a0_0x47b98e(0x1ea)](_0x3038ef,_0x37221e,_0xdf7541=a0_0x47b98e(0x18f)){const _0x4054d3=a0_0x47b98e;return Y({'alias':_0x3038ef,'fromAlias':this[_0x4054d3(0x199)]},{'log':_0x200355=>console['log'](_0x200355),'send':()=>this[_0x4054d3(0x1c4)](_0x4054d3(0x1da),{'alias':_0x3038ef,'task':_0x37221e,'priority':_0xdf7541,'from_session':this[_0x4054d3(0x199)]})});}async[a0_0x47b98e(0x1fa)](_0x3c4fea,_0x22d508){const _0x29d86b=a0_0x47b98e;return this[_0x29d86b(0x1c4)](_0x29d86b(0x1ae),{'alias':_0x3c4fea,'message':_0x22d508,'from_session':this[_0x29d86b(0x199)]});}async[a0_0x47b98e(0x18d)](_0x185662,_0x22b7c5,_0x3f0161='completed'){return this['call']('send_reply',{'in_reply_to':_0x185662,'text':_0x22b7c5,'status':_0x3f0161});}async[a0_0x47b98e(0x1a6)](_0x37bc6e,_0xff9159){const _0x1456c8=a0_0x47b98e;return this[_0x1456c8(0x1c4)](_0x1456c8(0x1d5),{'resume_id':this[_0x1456c8(0x1ca)],'alias':this[_0x1456c8(0x199)],'status':_0x37bc6e,'server':a0_0x15db84(),'hostname':a0_0x15db84(),'agent':this['agent'],'project_dir':process[_0x1456c8(0x194)](),..._0xff9159});}async['getAllStatus'](){const _0x4516de=a0_0x47b98e;return this['call'](_0x4516de(0x1f9),{});}async['broadcast'](_0x48655b,_0x44213e){const _0x238c5d=a0_0x47b98e;return this['call']('broadcast',{'message':_0x48655b,'filter_server':_0x44213e?.[_0x238c5d(0x1bb)],'filter_status':_0x44213e?.[_0x238c5d(0x1a6)]});}async[a0_0x47b98e(0x1f3)](){const _0x24dade=a0_0x47b98e;let _0x5263ce=encodeURIComponent(this['alias']),_0x497b72=this[_0x24dade(0x19b)]+_0x24dade(0x1f8)+_0x5263ce,_0x49ebb1=this[_0x24dade(0x1a8)];while(this['running']){try{this[_0x24dade(0x1e8)]=new AbortController();let _0x22ae62={'Accept':_0x24dade(0x1be)};if(this[_0x24dade(0x1bf)])_0x22ae62[_0x24dade(0x1fb)]='Bearer\x20'+this[_0x24dade(0x1bf)];let _0x5500e3=await fetch(_0x497b72,{'headers':_0x22ae62,'signal':this[_0x24dade(0x1e8)][_0x24dade(0x1f7)]});if(!_0x5500e3['ok']||!_0x5500e3[_0x24dade(0x1aa)]){this[_0x24dade(0x204)](_0x24dade(0x1cf)+_0x5500e3[_0x24dade(0x1a6)]),await this[_0x24dade(0x1d8)](_0x49ebb1),_0x49ebb1=Math[_0x24dade(0x1c7)](_0x49ebb1*1.5,0xea60);continue;}_0x49ebb1=this['reconnectDelay'];let _0x5976b7=_0x5500e3[_0x24dade(0x1aa)][_0x24dade(0x1d2)](),_0x344710=new TextDecoder(),_0x5c4a0f='';while(this[_0x24dade(0x196)]){let {done:_0x3d8b0c,value:_0x45b840}=await _0x5976b7[_0x24dade(0x1b8)]();if(_0x3d8b0c)break;_0x5c4a0f+=_0x344710['decode'](_0x45b840,{'stream':!0x0});let _0x4da248=_0x5c4a0f[_0x24dade(0x1e9)]('\x0a');_0x5c4a0f=_0x4da248[_0x24dade(0x1b1)]()||'';for(let _0x5a3fb7 of _0x4da248){if(!_0x5a3fb7['startsWith'](_0x24dade(0x1f4)))continue;try{let _0x38e673=JSON[_0x24dade(0x1cd)](_0x5a3fb7['slice'](0x6));if(_0x38e673[_0x24dade(0x1e2)]===_0x24dade(0x1ba)){this['log'](_0x24dade(0x195)),this[_0x24dade(0x1c0)](_0x24dade(0x1ba));continue;}if(_0x38e673[_0x24dade(0x1e2)]===_0x24dade(0x1eb)||_0x38e673['type']==='new_message'||_0x38e673[_0x24dade(0x1e2)]===_0x24dade(0x19f))await this['processInbox']();}catch{}}}}catch(_0x39f36e){if(_0x39f36e[_0x24dade(0x1d3)]===_0x24dade(0x1b4))break;this[_0x24dade(0x1c0)](_0x24dade(0x1e3),_0x39f36e),this[_0x24dade(0x204)](_0x24dade(0x1fe)+_0x39f36e[_0x24dade(0x1fa)]);}if(this[_0x24dade(0x196)])this[_0x24dade(0x1c0)]('disconnected'),this[_0x24dade(0x204)]('SSE\x20reconnecting\x20in\x20'+_0x49ebb1/0x3e8+_0x24dade(0x1cb)),await this[_0x24dade(0x1d8)](_0x49ebb1),_0x49ebb1=Math[_0x24dade(0x1c7)](_0x49ebb1*1.5,0xea60);}}async['processInbox'](){const _0x76bb32=a0_0x47b98e;try{let _0x5b7bc6=(await this[_0x76bb32(0x1c4)](_0x76bb32(0x1e5),{'alias':this[_0x76bb32(0x199)],'limit':0xa}))?.['messages']||[];for(let _0x43307c of _0x5b7bc6)await this['call'](_0x76bb32(0x1b6),{'alias':this[_0x76bb32(0x199)],'message_id':_0x43307c['id']}),this[_0x76bb32(0x204)]('←\x20'+_0x43307c[_0x76bb32(0x1a4)]+':\x20'+_0x43307c[_0x76bb32(0x1af)]['slice'](0x0,0x3c)),this[_0x76bb32(0x1c0)]('task',_0x43307c),this['emit'](_0x76bb32(0x1fa),_0x43307c);}catch(_0x31992f){this['log'](_0x76bb32(0x1d9)+_0x31992f[_0x76bb32(0x1fa)]);}}['sleep'](_0x568d71){return new Promise(_0x2efb8b=>setTimeout(_0x2efb8b,_0x568d71));}}var F=$;function a0_0x3421(_0x264e4f,_0x567026){_0x264e4f=_0x264e4f-0x185;const _0xbb260d=a0_0xbb26();let _0x3421c7=_0xbb260d[_0x264e4f];return _0x3421c7;}export{F as default,$ as CommHub};
1
+ const a0_0x5ee143=a0_0x47a0;(function(_0x155587,_0x221a50){const _0x197351=a0_0x47a0,_0x4f10f5=_0x155587();while(!![]){try{const _0x3a981d=parseInt(_0x197351(0x259))/0x1*(parseInt(_0x197351(0x20e))/0x2)+parseInt(_0x197351(0x26c))/0x3*(-parseInt(_0x197351(0x1fb))/0x4)+-parseInt(_0x197351(0x1f8))/0x5+parseInt(_0x197351(0x25b))/0x6+-parseInt(_0x197351(0x227))/0x7+parseInt(_0x197351(0x244))/0x8+-parseInt(_0x197351(0x1f9))/0x9*(-parseInt(_0x197351(0x1f2))/0xa);if(_0x3a981d===_0x221a50)break;else _0x4f10f5['push'](_0x4f10f5['shift']());}catch(_0x2c6ba6){_0x4f10f5['push'](_0x4f10f5['shift']());}}}(a0_0xc4ad,0xac360));import{EventEmitter as a0_0x2ef6bd}from'events';import{hostname as a0_0x632a9e}from'os';var K=/(?:atok|ntok|utok|ghp|github_pat)_[A-Za-z0-9_-]+|Bearer\s+\S+/gi,L=(_0x3a2fa4,_0x3c519f)=>(_0x3a2fa4??_0x3c519f)['replace'](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);function N(_0xb6f65a){const _0x30a036=a0_0x47a0;return(_0xb6f65a instanceof Error?_0xb6f65a[_0x30a036(0x24f)]:String(_0xb6f65a??'unknown\x20error'))[_0x30a036(0x220)](K,_0x30a036(0x263))[_0x30a036(0x220)](/[\r\n\x00-\x1f\x7f]/g,'\x20')['slice'](0x0,0xf0);}function O(_0x125a6b,_0x4b0ea6=process.env.ANET_TASK_TRACE_FORMAT===a0_0x5ee143(0x208)){const _0x4035cf=a0_0x5ee143;if(_0x4b0ea6)return JSON['stringify'](_0x125a6b);let _0x1d0103=L(_0x125a6b[_0x4035cf(0x225)],_0x4035cf(0x1ff)),_0x1a31c0=L(_0x125a6b['task_id'],_0x4035cf(0x215)),_0x55cd7d=_0x125a6b['error_code']?_0x4035cf(0x24d)+_0x125a6b[_0x4035cf(0x22e)]+':'+(_0x125a6b['error_message']??''):'';return _0x4035cf(0x200)+_0x125a6b[_0x4035cf(0x214)]+_0x4035cf(0x262)+L(_0x125a6b[_0x4035cf(0x25e)],'<unknown>')+_0x4035cf(0x202)+L(_0x125a6b['to_alias'],_0x4035cf(0x229))+_0x4035cf(0x249)+_0x1a31c0+_0x4035cf(0x1fe)+_0x1d0103+_0x4035cf(0x232)+L(_0x125a6b[_0x4035cf(0x210)],_0x4035cf(0x229))+_0x4035cf(0x213)+_0x125a6b[_0x4035cf(0x207)]+'\x20duration_ms='+_0x125a6b[_0x4035cf(0x21e)]+_0x4035cf(0x25c)+_0x125a6b['lifecycle_tracking']+_0x55cd7d;}function U(_0x4e84d3){const _0x5b823a=a0_0x5ee143;return{'event':{'sending':_0x5b823a(0x270),'delivered':_0x5b823a(0x24b),'failed':'task.send.failed','acked':_0x5b823a(0x24e),'started':_0x5b823a(0x246),'replied':'task.replied','expired':_0x5b823a(0x22d)}[_0x4e84d3[_0x5b823a(0x214)]],..._0x4e84d3};}function a0_0xc4ad(){const _0x4fd9c4=['<missing>','[commhub:task]\x20','processInbox','\x20to=','log','from_session','delivered','ack_inbox','transport','json','message_id','alias','error','Authorization','sdk','6680nxEHRc','send_reply','network_id','task','send_task','\x20transport=','status','<pending>','match','reconnectDelay','sdk-','getReader','2.0','sleep','lifecycleTracking','task_id','duration_ms','sseAbort','replace','connected','string','url','text','parent_task_id','abort','1824767RJHjna','new_message','<unknown>','agent','connect','new_task','task.expired','error_code','catch','startsWith','missing_task_id','\x20network_id=','heartbeatInterval','SSE\x20failed:\x20','autoConnect','server','parse','fromAlias','running','get_all_status','POST','reply',']\x20[commhub:','toAlias','signal','result','disconnected','pop','heartbeatTimer','6156544cQtlwP','type','task.started','send','send_failed','\x20task_id=','split','task.send.delivered','broadcast','\x20error=','task.ack','message','/events/','Bearer\x20','SSE\x20reconnecting\x20in\x20','failed','networkId','connectSSE','parentTaskId','heartbeat\x20failed:\x20','stringify','89edcJXd','name','3279714xbLqTH','\x20lifecycle=','text/event-stream','from_alias','AbortError','registered','body','\x20from=','[REDACTED]','tools/call','not_tracked','now','emit','get_inbox','min','decode','completed','429393KErRcd','cwd','toString','content','task.send.start','20JsdIXi','application/json','token','inbox\x20error:\x20','SSE\x20connected','idle','5244030gUjPNj','3094551ewqLkl','slice','8wbGvrE','/mcp','call','\x20parent_task_id='];a0_0xc4ad=function(){return _0x4fd9c4;};return a0_0xc4ad();}function j(_0x2aead7){const _0x91b23e=a0_0x5ee143;let _0x19383a=_0x2aead7?.[_0x91b23e(0x21d)]||_0x2aead7?.['message_id']||_0x2aead7?.['id'];if(_0x19383a)return String(_0x19383a);let _0x45c8c2=_0x2aead7?.[_0x91b23e(0x26f)]?.[0x0]?.[_0x91b23e(0x224)];if(typeof _0x45c8c2!==_0x91b23e(0x222))return null;try{let _0x32ec64=JSON['parse'](_0x45c8c2);return _0x32ec64?.[_0x91b23e(0x21d)]||_0x32ec64?.[_0x91b23e(0x209)]||_0x32ec64?.['id']||null;}catch{return null;}}async function X(_0x3692fe,_0x4fca27){const _0x484551=a0_0x5ee143;let _0x1ab3ce=_0x4fca27[_0x484551(0x266)]??Date[_0x484551(0x266)],_0xe9b360=_0x1ab3ce(),_0x46b2b3=(_0xb8fd3c,_0x20eaf7,_0x715ff4,_0x198cb2)=>{const _0x1e9d7e=_0x484551;_0x4fca27['log'](O(U({'from_alias':_0x3692fe[_0x1e9d7e(0x238)],'to_alias':_0x3692fe[_0x1e9d7e(0x23e)],'task_id':_0x20eaf7,'parent_task_id':_0x3692fe['parentTaskId'],'network_id':_0x3692fe[_0x1e9d7e(0x254)],'transport':_0x3692fe[_0x1e9d7e(0x207)],'status':_0xb8fd3c,'duration_ms':_0x1ab3ce()-_0xe9b360,'lifecycle_tracking':_0x3692fe[_0x1e9d7e(0x21c)],..._0x715ff4!==void 0x0?{'error_code':_0x198cb2||_0x1e9d7e(0x248),'error_message':N(_0x715ff4)}:{}})));};_0x46b2b3('sending',null);try{let _0x1e4259=await _0x4fca27['send'](),_0x2f07f6=j(_0x1e4259);if(_0x2f07f6)_0x46b2b3(_0x484551(0x205),_0x2f07f6);else{if(_0x1e4259?.['ok']===!0x1||_0x1e4259?.[_0x484551(0x20b)])_0x46b2b3('failed',_0x2f07f6,_0x1e4259?.['error']||'CommHub\x20rejected\x20task','send_rejected');else _0x46b2b3(_0x484551(0x253),null,'CommHub\x20response\x20omitted\x20task_id',_0x484551(0x231));}return _0x1e4259;}catch(_0x35d2c4){throw _0x46b2b3(_0x484551(0x253),null,_0x35d2c4,_0x484551(0x248)),_0x35d2c4;}}async function Y(_0xaeb0b1,_0x942882){const _0x4876e5=a0_0x5ee143;return X({'fromAlias':_0xaeb0b1[_0x4876e5(0x238)],'toAlias':_0xaeb0b1[_0x4876e5(0x20a)],'parentTaskId':_0xaeb0b1[_0x4876e5(0x256)]||null,'networkId':_0xaeb0b1['networkId']||null,'transport':'mcp_http','lifecycleTracking':_0x4876e5(0x265)},_0x942882);}class $ extends a0_0x2ef6bd{[a0_0x5ee143(0x223)];['alias'];[a0_0x5ee143(0x1f4)];['agent'];['resumeId'];['heartbeatInterval'];['reconnectDelay'];['heartbeatTimer'];[a0_0x5ee143(0x21f)];['running']=!0x1;constructor(_0x27168e){const _0x5af963=a0_0x5ee143;super();if(this[_0x5af963(0x223)]=_0x27168e[_0x5af963(0x223)][_0x5af963(0x220)](/\/$/,''),this['alias']=_0x27168e[_0x5af963(0x20a)],this[_0x5af963(0x1f4)]=_0x27168e['token'],this[_0x5af963(0x22a)]=_0x27168e['agent']||_0x5af963(0x20d),this['resumeId']=_0x5af963(0x218)+_0x27168e[_0x5af963(0x20a)]+'-'+Date[_0x5af963(0x266)]()[_0x5af963(0x26e)](0x24),this[_0x5af963(0x233)]=_0x27168e[_0x5af963(0x233)]??0x2bf20,this[_0x5af963(0x217)]=_0x27168e[_0x5af963(0x217)]??0xbb8,_0x27168e[_0x5af963(0x235)]!==!0x1)this[_0x5af963(0x22b)]();}[a0_0x5ee143(0x203)](_0x27d0f0){const _0x360338=a0_0x5ee143;console['log']('['+new Date()['toTimeString']()[_0x360338(0x1fa)](0x0,0x8)+_0x360338(0x23d)+this[_0x360338(0x20a)]+']\x20'+_0x27d0f0);}async[a0_0x5ee143(0x1fd)](_0x53d031,_0x4cdb2f){const _0x3cd678=a0_0x5ee143;let _0x548c90={'Content-Type':_0x3cd678(0x1f3),'Accept':'application/json,\x20text/event-stream'};if(this[_0x3cd678(0x1f4)])_0x548c90[_0x3cd678(0x20c)]=_0x3cd678(0x251)+this['token'];let _0x157388=await(await fetch(this[_0x3cd678(0x223)]+_0x3cd678(0x1fc),{'method':_0x3cd678(0x23b),'headers':_0x548c90,'body':JSON[_0x3cd678(0x258)]({'jsonrpc':_0x3cd678(0x21a),'id':Date[_0x3cd678(0x266)](),'method':_0x3cd678(0x264),'params':{'name':_0x53d031,'arguments':_0x4cdb2f}})}))[_0x3cd678(0x224)](),_0x521fad=_0x157388[_0x3cd678(0x216)](/data: (.+)/),_0x5b26d4=_0x521fad?JSON[_0x3cd678(0x237)](_0x521fad[0x1]):JSON['parse'](_0x157388),_0x16700b=_0x5b26d4?.[_0x3cd678(0x240)]?.[_0x3cd678(0x26f)]?.[0x0]?.['text'];return _0x16700b?JSON['parse'](_0x16700b):_0x5b26d4;}async[a0_0x5ee143(0x22b)](){const _0xba34b6=a0_0x5ee143;if(this[_0xba34b6(0x239)])return;this[_0xba34b6(0x239)]=!0x0,await this['status'](_0xba34b6(0x1f7)),this[_0xba34b6(0x203)](_0xba34b6(0x260)),this[_0xba34b6(0x243)]=setInterval(()=>{const _0x5ac420=_0xba34b6;this[_0x5ac420(0x214)]('idle')[_0x5ac420(0x22f)](_0x252f58=>this['log'](_0x5ac420(0x257)+_0x252f58[_0x5ac420(0x24f)]));},this[_0xba34b6(0x233)]),this[_0xba34b6(0x255)]();}async['disconnect'](){const _0x1887ee=a0_0x5ee143;if(this['running']=!0x1,this['sseAbort']?.[_0x1887ee(0x226)](),this['heartbeatTimer'])clearInterval(this['heartbeatTimer']);await this['status']('offline')[_0x1887ee(0x22f)](()=>{}),this['log'](_0x1887ee(0x241));}async[a0_0x5ee143(0x247)](_0x532619,_0x178eca,_0x3aec7d='normal'){const _0x294d2a=a0_0x5ee143;return Y({'alias':_0x532619,'fromAlias':this[_0x294d2a(0x20a)]},{'log':_0x1ec875=>console[_0x294d2a(0x203)](_0x1ec875),'send':()=>this['call'](_0x294d2a(0x212),{'alias':_0x532619,'task':_0x178eca,'priority':_0x3aec7d,'from_session':this[_0x294d2a(0x20a)]})});}async[a0_0x5ee143(0x24f)](_0x1aa859,_0x5ac592){const _0x5755cb=a0_0x5ee143;return this['call']('send_message',{'alias':_0x1aa859,'message':_0x5ac592,'from_session':this[_0x5755cb(0x20a)]});}async[a0_0x5ee143(0x23c)](_0x413a4a,_0x561e70,_0x2ca605=a0_0x5ee143(0x26b)){const _0x419f02=a0_0x5ee143;return this[_0x419f02(0x1fd)](_0x419f02(0x20f),{'in_reply_to':_0x413a4a,'text':_0x561e70,'status':_0x2ca605});}async[a0_0x5ee143(0x214)](_0x74d946,_0x35a2a0){const _0x5f0948=a0_0x5ee143;return this['call']('report_status',{'resume_id':this['resumeId'],'alias':this['alias'],'status':_0x74d946,'server':a0_0x632a9e(),'hostname':a0_0x632a9e(),'agent':this[_0x5f0948(0x22a)],'project_dir':process[_0x5f0948(0x26d)](),..._0x35a2a0});}async['getAllStatus'](){const _0x5b8abb=a0_0x5ee143;return this[_0x5b8abb(0x1fd)](_0x5b8abb(0x23a),{});}async[a0_0x5ee143(0x24c)](_0x1a54a6,_0x4ee7d4){const _0x1be47f=a0_0x5ee143;return this[_0x1be47f(0x1fd)]('broadcast',{'message':_0x1a54a6,'filter_server':_0x4ee7d4?.[_0x1be47f(0x236)],'filter_status':_0x4ee7d4?.[_0x1be47f(0x214)]});}async[a0_0x5ee143(0x255)](){const _0xb6fbf8=a0_0x5ee143;let _0x2f48ed=encodeURIComponent(this[_0xb6fbf8(0x20a)]),_0x3aa0e8=this[_0xb6fbf8(0x223)]+_0xb6fbf8(0x250)+_0x2f48ed,_0x8942d=this['reconnectDelay'];while(this[_0xb6fbf8(0x239)]){try{this['sseAbort']=new AbortController();let _0x9e1d6f={'Accept':_0xb6fbf8(0x25d)};if(this[_0xb6fbf8(0x1f4)])_0x9e1d6f['Authorization']=_0xb6fbf8(0x251)+this[_0xb6fbf8(0x1f4)];let _0x46b31d=await fetch(_0x3aa0e8,{'headers':_0x9e1d6f,'signal':this[_0xb6fbf8(0x21f)][_0xb6fbf8(0x23f)]});if(!_0x46b31d['ok']||!_0x46b31d[_0xb6fbf8(0x261)]){this[_0xb6fbf8(0x203)](_0xb6fbf8(0x234)+_0x46b31d[_0xb6fbf8(0x214)]),await this[_0xb6fbf8(0x21b)](_0x8942d),_0x8942d=Math[_0xb6fbf8(0x269)](_0x8942d*1.5,0xea60);continue;}_0x8942d=this['reconnectDelay'];let _0x1c7610=_0x46b31d[_0xb6fbf8(0x261)][_0xb6fbf8(0x219)](),_0x227a37=new TextDecoder(),_0x4594b2='';while(this['running']){let {done:_0x257131,value:_0x5ec87b}=await _0x1c7610['read']();if(_0x257131)break;_0x4594b2+=_0x227a37[_0xb6fbf8(0x26a)](_0x5ec87b,{'stream':!0x0});let _0x122982=_0x4594b2[_0xb6fbf8(0x24a)]('\x0a');_0x4594b2=_0x122982[_0xb6fbf8(0x242)]()||'';for(let _0x153a8b of _0x122982){if(!_0x153a8b[_0xb6fbf8(0x230)]('data:\x20'))continue;try{let _0x56ecfa=JSON[_0xb6fbf8(0x237)](_0x153a8b[_0xb6fbf8(0x1fa)](0x6));if(_0x56ecfa['type']===_0xb6fbf8(0x221)){this[_0xb6fbf8(0x203)](_0xb6fbf8(0x1f6)),this['emit'](_0xb6fbf8(0x221));continue;}if(_0x56ecfa[_0xb6fbf8(0x245)]===_0xb6fbf8(0x22c)||_0x56ecfa[_0xb6fbf8(0x245)]===_0xb6fbf8(0x228)||_0x56ecfa[_0xb6fbf8(0x245)]===_0xb6fbf8(0x24c))await this[_0xb6fbf8(0x201)]();}catch{}}}}catch(_0x49f5ae){if(_0x49f5ae[_0xb6fbf8(0x25a)]===_0xb6fbf8(0x25f))break;this['emit'](_0xb6fbf8(0x20b),_0x49f5ae),this[_0xb6fbf8(0x203)]('SSE\x20error:\x20'+_0x49f5ae[_0xb6fbf8(0x24f)]);}if(this[_0xb6fbf8(0x239)])this[_0xb6fbf8(0x267)](_0xb6fbf8(0x241)),this[_0xb6fbf8(0x203)](_0xb6fbf8(0x252)+_0x8942d/0x3e8+'s...'),await this[_0xb6fbf8(0x21b)](_0x8942d),_0x8942d=Math['min'](_0x8942d*1.5,0xea60);}}async[a0_0x5ee143(0x201)](){const _0x4fa3d7=a0_0x5ee143;try{let _0x4a7c6e=(await this[_0x4fa3d7(0x1fd)](_0x4fa3d7(0x268),{'alias':this[_0x4fa3d7(0x20a)],'limit':0xa}))?.['messages']||[];for(let _0x41039d of _0x4a7c6e)await this[_0x4fa3d7(0x1fd)](_0x4fa3d7(0x206),{'alias':this[_0x4fa3d7(0x20a)],'message_id':_0x41039d['id']}),this[_0x4fa3d7(0x203)]('←\x20'+_0x41039d[_0x4fa3d7(0x204)]+':\x20'+_0x41039d[_0x4fa3d7(0x26f)][_0x4fa3d7(0x1fa)](0x0,0x3c)),this[_0x4fa3d7(0x267)](_0x4fa3d7(0x211),_0x41039d),this['emit'](_0x4fa3d7(0x24f),_0x41039d);}catch(_0x7f6e93){this[_0x4fa3d7(0x203)](_0x4fa3d7(0x1f5)+_0x7f6e93[_0x4fa3d7(0x24f)]);}}[a0_0x5ee143(0x21b)](_0x3af990){return new Promise(_0xc7c937=>setTimeout(_0xc7c937,_0x3af990));}}function a0_0x47a0(_0x455243,_0xd57dea){_0x455243=_0x455243-0x1f2;const _0xc4ad64=a0_0xc4ad();let _0x47a068=_0xc4ad64[_0x455243];return _0x47a068;}var F=$;export{F as default,$ as CommHub};
@@ -13,5 +13,18 @@ export interface MigratedCodexPendingThread {
13
13
  */
14
14
  export declare function migrateCodexPendingThread(value: unknown, oldServerUrl: unknown, expectedOldMarker: unknown, newServerUrl: string, newMarker: string): MigratedCodexPendingThread;
15
15
  export declare function requirePromotedCodexPendingThread(value: unknown, pendingThreadId: string): string;
16
+ /**
17
+ * argv for the human TUI attached to the co-presence app-server.
18
+ *
19
+ * #505 — the permission override is only passed on the FRESH path. On
20
+ * `resume --remote <ws> <thread>` codex 0.155.1 exits immediately with
21
+ * "Error: Permission overrides are not supported when resuming a remote task."
22
+ * (anet then reports "TUI tmux session exited during startup"). Measured in
23
+ * Docker against a real app-server + real thread: 0.155.1 rejects
24
+ * resume + --dangerously-bypass-approvals-and-sandbox and accepts it fresh
25
+ * (TUI up, "permissions: YOLO mode"); 0.133.0 (agent-node's pin) accepts both.
26
+ * Nothing is lost by dropping it on resume: the app-server itself is started
27
+ * with `-c approval_policy=… -c sandbox_mode=…` from the same posture.
28
+ */
16
29
  export declare function codexTuiLaunchArgs(remote: string, model: string, threadId?: string, dangerFullAccess?: boolean): string[];
17
30
  export declare function assertPendingServerQuiesced(serverUrl: unknown, isListening: (port: number) => boolean | Promise<boolean>): Promise<void>;
@@ -0,0 +1,64 @@
1
+ export declare const COMMHUB_SERVER_PKG = "@sleep2agi/commhub-server";
2
+ export declare const AGENT_NETWORK_PKG = "@sleep2agi/agent-network";
3
+ export type HubReleaseChannel = "latest" | "preview";
4
+ export type HubVersionSource = "explicit" | "registry" | "cache" | "pinned-floor";
5
+ export interface DistTags {
6
+ latest?: string | null;
7
+ preview?: string | null;
8
+ }
9
+ export declare function isExactSemver(v: string | null | undefined): boolean;
10
+ /** Semver precedence. Unparseable versions sort lowest. */
11
+ export declare function compareSemver(a: string, b: string): number;
12
+ export declare function resolveHubChannel(input: {
13
+ anetVersion: string;
14
+ flag?: string | null;
15
+ anetDistTags: DistTags | null;
16
+ }): {
17
+ channel: HubReleaseChannel;
18
+ reason: string;
19
+ };
20
+ export interface HubVersionDecision {
21
+ version: string;
22
+ source: HubVersionSource;
23
+ channel: HubReleaseChannel | null;
24
+ /** true when `version` is already present in the local bun install cache. */
25
+ cached: boolean;
26
+ /** One-line, human readable "where it came from". */
27
+ origin: string;
28
+ /** Must be printed prominently (stderr). */
29
+ warnings: string[];
30
+ }
31
+ export declare function decideHubServerVersion(input: {
32
+ explicit?: string | null;
33
+ channelFlag?: string | null;
34
+ anetVersion: string;
35
+ anetDistTags: DistTags | null;
36
+ serverDistTags: DistTags | null;
37
+ floor: string;
38
+ cachedVersions: string[];
39
+ }): HubVersionDecision;
40
+ export type ExecFn = (cmd: string, args: string[]) => string;
41
+ export declare function fetchDistTags(exec: ExecFn, pkg: string): DistTags | null;
42
+ export interface CacheFs {
43
+ existsSync(p: string): boolean;
44
+ readdirSync(p: string): string[];
45
+ readFileSync(p: string): string;
46
+ }
47
+ export declare function bunInstallCacheDir(env?: NodeJS.ProcessEnv, home?: string): string;
48
+ /**
49
+ * Versions of commhub-server present in bun's install cache. Bun uses two
50
+ * layouts (`@sleep2agi/commhub-server@<ver-or-hash>@@@1/` and
51
+ * `@sleep2agi/commhub-server/<ver-or-hash>@@@1/`); prerelease parts are
52
+ * hashed in the directory name, so the version is read from package.json.
53
+ */
54
+ export declare function listCachedServerVersions(cacheDir: string, fs?: CacheFs): string[];
55
+ export declare function resolveHubServerVersion(input: {
56
+ explicit?: string | null;
57
+ channelFlag?: string | null;
58
+ anetVersion: string;
59
+ floor: string;
60
+ exec: ExecFn;
61
+ cacheDir: string;
62
+ fs?: CacheFs;
63
+ }): HubVersionDecision;
64
+ export declare function formatHubVersionBanner(d: HubVersionDecision): string;
@@ -0,0 +1,35 @@
1
+ export interface NodeIdentityFromConfig {
2
+ node_id?: string;
3
+ node_name?: string;
4
+ model?: string;
5
+ }
6
+ export declare function nodeIdentityFromConfig(path: string | undefined): NodeIdentityFromConfig;
7
+ export interface NodeRowLike {
8
+ node_id?: string | null;
9
+ alias?: string | null;
10
+ runtime?: string | null;
11
+ config_path?: string | null;
12
+ }
13
+ export type NodeIdClaimVerdict = {
14
+ claim: true;
15
+ } | {
16
+ claim: false;
17
+ owner: string;
18
+ runtime: string | null;
19
+ config_path: string | null;
20
+ };
21
+ export declare function nodeIdClaimVerdict(nodeId: string, rows: readonly NodeRowLike[], alias: string): NodeIdClaimVerdict;
22
+ export type NodeIdClaimState = "ok" | "conflict" | "unknown";
23
+ /** 取 hub 上这个 node_id 的行并下结论;任何失败都是 "unknown"(调用方这次不报 node_id)。 */
24
+ export declare function checkNodeIdClaim(opts: {
25
+ hubUrl: string;
26
+ token: string;
27
+ nodeId: string;
28
+ alias: string;
29
+ fetchImpl?: typeof fetch;
30
+ timeoutMs?: number;
31
+ }): Promise<{
32
+ state: NodeIdClaimState;
33
+ verdict?: NodeIdClaimVerdict;
34
+ error?: string;
35
+ }>;